Add RAII wrapper for GTKDisableEvents/GTKEnableEvents() calls
Ensure GTKEnableEvents() is called automatically on scope exit whenever GTKDisableEvents() is called. This fixes a couple of potential bugs where GTKEnableEvents() could be not called if wxCHECK() condition failed and makes the code shorter and safer.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/gtk/private/gtk2-compat.h"
|
||||
#include "wx/gtk/private/eventsdisabler.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GTK callbacks
|
||||
@@ -155,7 +156,7 @@ void wxChoice::DoClear()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid control") );
|
||||
|
||||
GTKDisableEvents();
|
||||
wxGtkEventsDisabler<wxChoice> noEvents(this);
|
||||
|
||||
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
|
||||
GtkTreeModel* model = gtk_combo_box_get_model( combobox );
|
||||
@@ -166,8 +167,6 @@ void wxChoice::DoClear()
|
||||
if (m_strings)
|
||||
m_strings->Clear();
|
||||
|
||||
GTKEnableEvents();
|
||||
|
||||
InvalidateBestSize();
|
||||
}
|
||||
|
||||
@@ -290,12 +289,10 @@ void wxChoice::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid control") );
|
||||
|
||||
GTKDisableEvents();
|
||||
wxGtkEventsDisabler<wxChoice> noEvents(this);
|
||||
|
||||
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
|
||||
gtk_combo_box_set_active( combobox, n );
|
||||
|
||||
GTKEnableEvents();
|
||||
}
|
||||
|
||||
void wxChoice::SetColumns(int n)
|
||||
|
Reference in New Issue
Block a user