diff --git a/cuegui/cuegui/Comments.py b/cuegui/cuegui/Comments.py index 2e54b19cd..bf6caca82 100644 --- a/cuegui/cuegui/Comments.py +++ b/cuegui/cuegui/Comments.py @@ -230,7 +230,13 @@ def refreshComments(self): last_items = [] for i in range(self.__treeSubjects.topLevelItemCount()): comment_source = self.__treeSubjects.topLevelItem(i) - last_items.append(comment_source.child(comment_source.childCount()-1)) + comment = comment_source.child(comment_source.childCount()-1) + if comment: + last_items.append(comment) + if not last_items: + self.__createNewComment() + return + identical = all(item.getInstance().message() == last_items[0].getInstance().message() and item.getInstance().subject() == last_items[0].getInstance().subject() for item in last_items) diff --git a/cuegui/tests/Comments_tests.py b/cuegui/tests/Comments_tests.py index 133bd7a6c..26266e3fb 100644 --- a/cuegui/tests/Comments_tests.py +++ b/cuegui/tests/Comments_tests.py @@ -59,8 +59,9 @@ def setUp(self, getStubMock): def test_shouldDisplayComment(self): self.assertEqual( 1, self.commentListDialog._CommentListDialog__treeSubjects.topLevelItemCount()) - gotTreeWidgetItem = self.commentListDialog._CommentListDialog__treeSubjects.topLevelItem(0) - gotComment = gotTreeWidgetItem._Comment__comment + commentSource = self.commentListDialog._CommentListDialog__treeSubjects.topLevelItem(0) + self.assertEqual(1, len(commentSource.__source)) + gotComment = commentSource.__source[0]._Comment__comment self.assertEqual(self.comment.timestamp(), gotComment.timestamp()) self.assertEqual(self.comment.user(), gotComment.user()) self.assertEqual(self.comment.subject(), gotComment.subject())