-
Notifications
You must be signed in to change notification settings - Fork 323
Do not clear messages list when user clicks No. #60
base: master
Are you sure you want to change the base?
Do not clear messages list when user clicks No. #60
Conversation
(Not the maintainer. I'm just interested in this.) I can reproduce this bug, but I couldn't figure out why it occurs because the existing code looks correct to me:
But the existing comment actually reveals the bug: "Should delete emails before calling observers, since observers will clean the model." MailsListPane observes ClearAllButton, and it clears the email list regardless of which button was clicked. ( The change looks good to me, but I haven't tested it. Thanks for contributing, @mathieu-bourdin. |
Thanks for your interest, a more detailed explanation below. Behaviour on
Behaviour on
Now, let's see what happens in On masterif (answer == JOptionPane.CLOSED_OPTION) {
return;
}
synchronized (SMTPServerHandler.INSTANCE.getMailSaver().getLock()) {
// Note: Should delete emails before calling observers, since observers will clean the model.
if (answer == JOptionPane.YES_OPTION) {
SMTPServerHandler.INSTANCE.getMailSaver().deleteEmails();
}
setChanged();
notifyObservers();
button.setEnabled(false);
} Clicking 'No' yields The fixif (answer != JOptionPane.YES_OPTION) {
return;
}
synchronized (SMTPServerHandler.INSTANCE.getMailSaver().getLock()) {
// Note: Should delete emails before calling observers, since observers will clean the model.
SMTPServerHandler.INSTANCE.getMailSaver().deleteEmails();
setChanged();
notifyObservers();
button.setEnabled(false);
} Return immediately if By the way, fakeSMTP is a really great tool, and this is just nitpicking. I mean as long as eml files are not deleted when user clicks No... this is more or less a cosmetic issue. |
Closed by a missclick :) |
found the same bug. #70 |
@sharpedavid When you click No, the email are not delted, but the button still notifys the observers about a change (that actually did not happen) leading the listView to be cleared. The fix is good. But the cause of the bug is acutal a conceptual problem that the Button that triggers an Action is an Observable. Normally the Model and not an Action is Observable. |
The title is pretty self explanatory...