lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 86b0c83 3/3: Repaint area covered by SingleCh


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 86b0c83 3/3: Repaint area covered by SingleChoicePopupMenu after showing it
Date: Sun, 5 Nov 2017 12:57:18 -0500 (EST)

branch: master
commit 86b0c833336b1d1f16144caadd369e756ee26509
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Repaint area covered by SingleChoicePopupMenu after showing it
    
    This is a workaround for a problem of the toolbar of the census view not
    repainting after selecting "Print roster to spreadsheet" from the popup
    menu shown by one of its toolbar button handlers.
    
    Unfortunately, this is somewhat of a hack, as it involves yielding,
    because neither Refresh()-ing nor even Update()-ing the native MSW
    toolbar control is sufficient to make it repaint immediately. At least
    we can only yield for the UI events, such as wxEVT_PAINT, and so don't
    run the risk of reentrancies due to getting some input event, as would
    be the case if we just called the global wxYield().
    
    Also notice that, while this fix could be applied just to
    census_view.cpp, as the only other current use of SingleChoicePopupMenu
    is in docmanager_ex.cpp, where this problem doesn't arise, it seems more
    foresighted to do it here, to ensure that it never happens again even if
    this class is used elsewhere.
---
 single_choice_popup_menu.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/single_choice_popup_menu.cpp b/single_choice_popup_menu.cpp
index 276b234..b424647 100644
--- a/single_choice_popup_menu.cpp
+++ b/single_choice_popup_menu.cpp
@@ -23,6 +23,7 @@
 
 #include "single_choice_popup_menu.hpp"
 
+#include <wx/evtloop.h>
 #include <wx/window.h>
 
 SingleChoicePopupMenu::SingleChoicePopupMenu
@@ -51,5 +52,15 @@ SingleChoicePopupMenu::SingleChoicePopupMenu
 int SingleChoicePopupMenu::Choose()
 {
     int const selection_index = parent_.GetPopupMenuSelectionFromUser(menu_);
+
+    if (wxEventLoopBase* const loop = wxEventLoopBase::GetActive())
+        {
+        // This function can often be used to get users choice before starting
+        // some time-consuming operation. Ensure that the area previously
+        // covered by the menu shown by GetPopupMenuSelectionFromUser() is
+        // repainted to avoid leaving it invalidated for a possibly long time.
+        loop->YieldFor(wxEVT_CATEGORY_UI);
+        }
+
     return selection_index != wxID_NONE ? selection_index : -1;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]