Avoid using already-destroyed parts of wxChoice/wxComboBox during destruction

When used as a wxDVC cell editor, GtkComboBox has already destroyed
it's model and child GtkEntry by the time our dtor is called.
See #17034
This commit is contained in:
Paul Cornett 2018-02-03 22:28:35 -08:00
parent 3a16250303
commit c391cfd617
2 changed files with 6 additions and 1 deletions

View File

@ -170,7 +170,8 @@ void wxChoice::DoClear()
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
GtkTreeModel* model = gtk_combo_box_get_model( combobox );
gtk_list_store_clear(GTK_LIST_STORE(model));
if (model)
gtk_list_store_clear(GTK_LIST_STORE(model));
m_clientData.Clear();

View File

@ -99,7 +99,10 @@ wxEND_EVENT_TABLE()
wxComboBox::~wxComboBox()
{
if (m_entry)
{
GTKDisconnect(m_entry);
g_object_remove_weak_pointer(G_OBJECT(m_entry), (void**)&m_entry);
}
}
void wxComboBox::Init()
@ -213,6 +216,7 @@ void wxComboBox::GTKCreateComboBoxWidget()
g_object_ref(m_widget);
m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
g_object_add_weak_pointer(G_OBJECT(m_entry), (void**)&m_entry);
}
GtkEditable *wxComboBox::GetEditable() const