----- Original Message ----- > Return early instead of call gtk_widget_get_window() with a NULL window, > avoiding segfaults when running on windows using GTK3. > > Program received signal SIGSEGV, Segmentation fault. > _gdk_windows_has_impl <window=window@entry=0x0> at gdkwindow.c:584 > <gdb> bt > #0 _gdk_window_has_impl (window=window@entry=0x0) at gdkwindow.c:584 > #1 0x70f02821 in gdk_win32_window_get_handle (window=0x0) at > gdkwindow-win32.c:3459 > #2 0x00c759ef in update_display (display=0x1b18440) at > spice-widget.c:1297 > #3 0x00c77280 in focus_in_event (widget=0x1b18440, focus=0x1b02b68) at > spice-widget.c:1462 > #4 0x665727f5 in ?? () from C:\Program Files\VirtViewer > (GTK3)\bin\libgtk-3-0.dll > #5 0x00000000 in ?? () > --- > Changes since v1: > - Improve the commit message/shortlog > - Use g_return_if_fail instead of g_warn_if_fail in update_display() > --- > gtk/spice-widget.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c > index ae11073..23aca93 100644 > --- a/gtk/spice-widget.c > +++ b/gtk/spice-widget.c > @@ -701,9 +701,12 @@ SpiceGrabSequence > *spice_display_get_grab_keys(SpiceDisplay *display) > static void try_keyboard_grab(SpiceDisplay *display) > { > GtkWidget *widget = GTK_WIDGET(display); > + GdkWindow *window = gtk_widget_get_window(widget); > SpiceDisplayPrivate *d = display->priv; > GdkGrabStatus status; > > + g_return_if_fail(window != NULL); > + > if (g_getenv("SPICE_NOGRAB")) > return; > if (d->disable_inputs) > @@ -731,8 +734,8 @@ static void try_keyboard_grab(SpiceDisplay *display) > GetModuleHandle(NULL), 0); > g_warn_if_fail(d->keyboard_hook != NULL); > #endif > - status = gdk_keyboard_grab(gtk_widget_get_window(widget), FALSE, > - GDK_CURRENT_TIME); > + > + status = gdk_keyboard_grab(window, FALSE, GDK_CURRENT_TIME); > if (status != GDK_GRAB_SUCCESS) { > g_warning("keyboard grab failed %d", status); > d->keyboard_grab_active = false; > @@ -1294,7 +1297,17 @@ static gboolean check_for_grab_key(SpiceDisplay > *display, int type, int keyval) > static void update_display(SpiceDisplay *display) > { > #ifdef G_OS_WIN32 > - win32_window = display ? > GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(display))) : NULL; > + GdkWindow *window; > + > + win32_window = NULL; > + > + if (display == NULL) > + return; > + > + window = gtk_widget_get_window(GTK_WIDGET(display)); > + g_return_if_fail (window != NULL); So if I get this right, it can still get a critical here, correct? I would suggest to check if the widget is realized instead. > + > + win32_window = GDK_WINDOW_HWND(window); > #endif > } > > -- > 2.1.0 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel > _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel