]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix text updated event generation in wxGTK wxComboBox.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Jul 2010 22:50:14 +0000 (22:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Jul 2010 22:50:14 +0000 (22:50 +0000)
The changes (cosmetic renaming, no less) in r64436 broke unit tests checking
for wxComboBox event generation because the extra text updated events were not
suppressed correctly any longer because wrong {Enable,Disable}Events() were
called instead of the correct GTK{Enable,Disable}Events().

Fix and slightly improve the code by disabling the events in overridden
EnableTextChangedEvents() itself and reuse its code from GTK-specific event
enabling functions.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/combobox.h
src/gtk/combobox.cpp

index b126e1c2ca8d327658f16b5b83e4f6955844c86e..df97c6bfcc09435223ad4866738a6807489a3b6f 100644 (file)
@@ -146,13 +146,7 @@ private:
     // From wxTextEntry:
     virtual wxWindow *GetEditableWindow() { return this; }
     virtual GtkEditable *GetEditable() const;
-    virtual void EnableTextChangedEvents(bool enable)
-    {
-        if ( enable )
-            EnableEvents();
-        else
-            DisableEvents();
-    }
+    virtual void EnableTextChangedEvents(bool enable);
 
     void Init();
 
index 1743505cac3c8d00db5c888469d38b84fe2a83d1..69c1373dde8c9ac096f4ba53a93f8184524d8ea3 100644 (file)
@@ -222,11 +222,26 @@ void wxComboBox::OnChar( wxKeyEvent &event )
     event.Skip();
 }
 
-void wxComboBox::GTKDisableEvents()
+void wxComboBox::EnableTextChangedEvents(bool enable)
 {
-    if ( GetEntry() )
+    if ( !GetEntry() )
+        return;
+
+    if ( enable )
+    {
+        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
+    }
+    else // disable
+    {
         g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
             (gpointer)gtkcombobox_text_changed_callback, this);
+    }
+}
+
+void wxComboBox::GTKDisableEvents()
+{
+    EnableTextChangedEvents(false);
 
     g_signal_handlers_block_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);
@@ -236,9 +251,7 @@ void wxComboBox::GTKDisableEvents()
 
 void wxComboBox::GTKEnableEvents()
 {
-    if ( GetEntry() )
-        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
-            (gpointer)gtkcombobox_text_changed_callback, this);
+    EnableTextChangedEvents(true);
 
     g_signal_handlers_unblock_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);