From cc2a5e8cc542d12e45f86845f01aaad23e9523cd Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 6 May 2015 19:58:41 -0300 Subject: [PATCH] Pressing two times BrushTypeField was making its popup always visible There was an ugly combination of events: 1. When ContextBar::BrushTypeField receives an onItemChange is because the mouse button is pressed on it (a kMouseDownMessage) 2. It shows the BrushPopup window (which is a PopupWindow with kCloseOnClickInOtherWindow click behavior) 3. When other click is made in BrushTypeField, the BrushPopup is closed because it is filtering messages (since it's kCloseOnClickInOtherWindow). This generates a kCloseMessage in the queue. 4. BrushTypeField::onItemChange() is executed again (for the same click in point 3), and it checks that the popup is closed (recently closed, by this click), so it shows the BrushPopup again. 5. The enqueued kCloseMessage is receved by PopupWindow, and it calls stopFilteringMessages(). So in this case we have a visible PopupWindow that is not filtering messages. To fix this bug we have included a startFilteringMessages() in kOpenMessage. So when the popup is shown again, it filters messages and the popup cannot stay visible. --- src/ui/popup_window.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ui/popup_window.cpp b/src/ui/popup_window.cpp index 8c6c7fed3..cb6b10a3d 100644 --- a/src/ui/popup_window.cpp +++ b/src/ui/popup_window.cpp @@ -67,6 +67,16 @@ bool PopupWindow::onProcessMessage(Message* msg) { switch (msg->type()) { + // There are cases where startFilteringMessages() is called when a + // kCloseMessage for this same PopupWindow is enqueued. Processing + // the kOpenMessage we ensure that the popup will be filtering + // messages if it's needed when it's visible (as kCloseMessage and + // kOpenMessage must be enqueued in the correct order). + case kOpenMessage: + if (!isMoveable()) + startFilteringMessages(); + break; + case kCloseMessage: stopFilteringMessages(); break; @@ -80,7 +90,7 @@ bool PopupWindow::onProcessMessage(Message* msg) if (m_filtering) { KeyMessage* keymsg = static_cast(msg); KeyScancode scancode = keymsg->scancode(); - + if (scancode == kKeyEsc || scancode == kKeyEnter || scancode == kKeyEnterPad) {