Fix bug and now warning will pop up if try to move to a new comment while editing some unsaved comment.
Review Request #8649 — Created Jan. 21, 2017 and discarded — Latest diff uploaded
Fix the bug of unsaved comment being discarded when creating/opening another comment.
For creating a new comment, the code creates a CommentBox(the little green box next to line number) first and then creates a new CommentDialog for editing. For opening another comment, the code only creates a new CommentDialog.
When creating the new CommentDialog, the "dirtiness" of existing CommentDialog is not checked, and thus the unsaved comments would be discarded.
After the fix, a check was done when creating the new CommentDialog. If the old CommentDialog is dirty, pop a warning message. If user chooses not to discard the unsaved comments, the new CommentDialog will not be created and the newly created CommentBox will be deleted in case of creating new comment. If user chooses to discard the unsaved comments, the code works the same way as before.
Test Preperation: create a comment (comment1), write something, and save it.
Test1: Create a comment (comment2), write something, and click on another line number trying to create another comment (comment3).
Test1 Result: Warning pops up.
Test1.1: Click "OK" on the warning popped up in Test1.
Test1.1 Result: comment2 is deleted, and dialog for comment3 pops up.
Test1.2: Click "cancel" on the warning popped up in Test1.
Test1.2 Result: comment3 is deleted, and dialog for comment2 stays in the screen.Test2: Create a comment (comment4), write something, and click on comment1 trying to open it.
Test2 Result: Warning pops up.
Test2.1: Click "OK" on the warning popped up in Test2.
Test2.1 Result: comment4 is deleted, and dialog for comment1 pops up.
Test2.2: Click "cancel" on the warning popped up in Test2.
Test2.2 Result: the dialog for comment4 stays in the screen, nothing happens to comment1.