diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-12-21 12:20:15 +0100 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-12-21 12:20:15 +0100 |
commit | 157d9271fa64074a3e1d92994adbcc073d4bc6ce (patch) | |
tree | b727de0b527b22be37d19d401aa98d82663ad53e /gtk/gtkapplication.c | |
parent | 72c04c064a1b35673ef6e65bd1c0d3389c029bd4 (diff) | |
download | gtk+-157d9271fa64074a3e1d92994adbcc073d4bc6ce.tar.gz |
application: don't unconditionally unref the GMenuModel in getters
Both the app-menu and menubar models can be NULL, so we shouldn't
blindly unref them, since g_object_unref() doesn't cope with NULL
pointers.
Diffstat (limited to 'gtk/gtkapplication.c')
-rw-r--r-- | gtk/gtkapplication.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index 5f428e241e..08d0117141 100644 --- a/gtk/gtkapplication.c +++ b/gtk/gtkapplication.c @@ -792,10 +792,12 @@ gtk_application_set_app_menu (GtkApplication *application, GMenuModel * gtk_application_get_app_menu (GtkApplication *application) { - GMenuModel *app_menu; + GMenuModel *app_menu = NULL; g_object_get (application, "app-menu", &app_menu, NULL); - g_object_unref (app_menu); + + if (app_menu) + g_object_unref (app_menu); return app_menu; } @@ -840,10 +842,12 @@ gtk_application_set_menubar (GtkApplication *application, GMenuModel * gtk_application_get_menubar (GtkApplication *application) { - GMenuModel *menubar; + GMenuModel *menubar = NULL; g_object_get (application, "menubar", &menubar, NULL); - g_object_unref (menubar); + + if (menubar) + g_object_unref (menubar); return menubar; } |