Cleaner fix for using deleted widget in idle callback
Use a slightly higher idle priority so callback runs before TLW is deleted, and ref the widget just to make sure it doesn't disappear. Avoids accessing de-allocated memory.
This commit is contained in:
@@ -1145,12 +1145,8 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
|
||||
extern "C" {
|
||||
static gboolean reset_size_request(void* data)
|
||||
{
|
||||
if ( GTK_IS_WIDGET(data) )
|
||||
{
|
||||
gtk_widget_set_size_request(GTK_WIDGET(data), -1, -1);
|
||||
}
|
||||
//else: the window has probably been deleted before the idle callback was
|
||||
// invoked
|
||||
g_object_unref(data);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1179,7 +1175,8 @@ void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
|
||||
{
|
||||
gtk_widget_set_size_request(m_wxwindow, m_clientWidth, m_clientHeight);
|
||||
// Cancel size request at next idle to allow resizing
|
||||
g_idle_add_full(G_PRIORITY_LOW, reset_size_request, m_wxwindow, NULL);
|
||||
g_idle_add_full(G_PRIORITY_LOW - 1, reset_size_request, m_wxwindow, NULL);
|
||||
g_object_ref(m_wxwindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user