diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c index 1c473303c1..7d047705e1 100644 --- a/gtk/gtkapplicationwindow.c +++ b/gtk/gtkapplicationwindow.c @@ -492,8 +492,9 @@ recalculate_app_menu_state (GtkApplicationWindow *window) } else { - gtk_widget_unparent (GTK_WIDGET (window->priv->menubar)); - g_object_unref (window->priv->menubar); + if (window->priv->menubar) + gtk_widget_unparent (GTK_WIDGET (window->priv->menubar)); + g_clear_object (&window->priv->menubar); } }