fixed traceback when deleting an author/topic which has just been added to an unsaved song

This commit is contained in:
Andreas Preikschat 2012-05-26 22:06:19 +02:00
parent cf59d89afa
commit 8241808d65
1 changed files with 6 additions and 2 deletions

View File

@ -865,12 +865,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for row in xrange(self.authorsListView.count()):
item = self.authorsListView.item(row)
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.song.authors.append(self.manager.get_object(Author, authorId))
author = self.manager.get_object(Author, authorId)
if author is not None:
self.song.authors.append(author)
self.song.topics = []
for row in xrange(self.topicsListView.count()):
item = self.topicsListView.item(row)
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.song.topics.append(self.manager.get_object(Topic, topicId))
topic = self.manager.get_object(Topic, topicId)
if topic is not None:
self.song.topics.append(topic)
# Save the song here because we need a valid id for the audio files.
clean_song(self.manager, self.song)
self.manager.save_object(self.song)