Allow modifying wxComboBox from its CLOSEUP handler with wxGTK2

Doing this resulted in GTK errors about invalid iterators, so postpone the
generation of the CLOSEUP event for slightly later to allow changing the
combobox contents from it with GTK+ 2 (this is not necessary with GTK+ 3).

Also add a demon of a dynamic combobox, creating and destroying its items on
the fly, to the widgets sample.

Closes #17223.
This commit is contained in:
Igor Korot
2016-02-24 20:07:34 +01:00
committed by Vadim Zeitlin
parent 62b5e1b2ef
commit a216806c99
3 changed files with 46 additions and 5 deletions

View File

@@ -55,7 +55,19 @@ gtkcombobox_popupshown_callback(GObject *WXUNUSED(gobject),
: wxEVT_COMBOBOX_CLOSEUP,
combo->GetId() );
event.SetEventObject( combo );
combo->HandleWindowEvent( event );
#ifndef __WXGTK3__
// Process the close up event once the combobox is already closed with GTK+
// 2, otherwise changing the combobox from its handler result in errors.
if ( !isShown )
{
combo->GetEventHandler()->AddPendingEvent( event );
}
else
#endif // GTK+ < 3
{
combo->HandleWindowEvent( event );
}
}
}