diff options
author | Alexandros Theodotou <alex@zrythm.org> | 2021-08-27 09:41:30 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-31 19:35:03 -0400 |
commit | 3a927b2640ec42d2570b4df8981a5b60e45b3999 (patch) | |
tree | bc36b127bc8252a4d8d260e4ffed889f1936a80a /src/x11_in_gtk3.c | |
parent | beebc304791447d850ddf181a3af563fe3cb5131 (diff) | |
download | suil-3a927b2640ec42d2570b4df8981a5b60e45b3999.tar.gz suil-3a927b2640ec42d2570b4df8981a5b60e45b3999.tar.bz2 suil-3a927b2640ec42d2570b4df8981a5b60e45b3999.zip |
Fix occasional segfault with X11 in Gtk3
This fixes an occasional segfault when idle_size_request() is called after the
widget has been destroyed.
Diffstat (limited to 'src/x11_in_gtk3.c')
-rw-r--r-- | src/x11_in_gtk3.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/x11_in_gtk3.c b/src/x11_in_gtk3.c index c93f3dd..dfc2dfc 100644 --- a/src/x11_in_gtk3.c +++ b/src/x11_in_gtk3.c @@ -50,6 +50,7 @@ typedef struct { const LV2UI_Idle_Interface* idle_iface; guint idle_id; guint idle_ms; + guint idle_size_request_id; int initial_width; int initial_height; int req_width; @@ -114,6 +115,11 @@ on_plug_removed(GtkSocket* sock, gpointer data) self->idle_id = 0; } + if (self->idle_size_request_id) { + g_source_remove(self->idle_size_request_id); + self->idle_size_request_id = 0; + } + if (self->instance->handle) { self->instance->descriptor->cleanup(self->instance->handle); self->instance->handle = NULL; @@ -207,8 +213,11 @@ forward_key_event(SuilX11Wrapper* socket, GdkEvent* gdk_event) static gboolean idle_size_request(gpointer user_data) { - GtkWidget* w = GTK_WIDGET(user_data); + SuilX11Wrapper* socket = (SuilX11Wrapper*)user_data; + GtkWidget* w = GTK_WIDGET(socket->plug); + gtk_widget_queue_resize(w); + socket->idle_size_request_id = 0; return FALSE; } @@ -264,7 +273,7 @@ forward_size_request(SuilX11Wrapper* socket, GtkAllocation* allocation) } else { /* Child has not been realized, so unable to resize now. Queue an idle resize. */ - g_idle_add(idle_size_request, socket->plug); + socket->idle_size_request_id = g_idle_add(idle_size_request, socket); } } |