From c391cfd6171c79968b44f0ed2e794aebcab010d8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 3 Feb 2018 22:28:35 -0800 Subject: [PATCH] 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 --- src/gtk/choice.cpp | 3 ++- src/gtk/combobox.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index db2240b11e..c65967ab1a 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -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(); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index e848edac65..4c0231dcf3 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -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