From 14df59d47c02e65e9ece747273a4bd2fa2dde97b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 13 Sep 2011 16:16:28 +0100 Subject: [PATCH] Fix a segfault if the GAppInfo does not have an icon This fixes the following backtrace: 0 g_logv (log_domain=0x7ffff60461a4 "GLib-GObject", log_level=, format=0x7ffff599c322 "%s: assertion `%s' failed", args1=0x7fffffffc418) at gmessages.c:577 1 0x00007ffff59312d2 in g_log (log_domain=, log_level=, format=) at gmessages.c:591 2 0x00007ffff601c3c7 in g_object_ref (_object=0x0) at gobject.c:2648 3 0x00007ffff7721e22 in gdk_x11_app_launch_context_get_startup_notify_id (context=, info=0x7fffe8004b40, files=) at gdkapplaunchcontext-x11.c:331 4 0x00007ffff62e60d0 in _g_desktop_app_info_launch_uris_internal (appinfo=0x7fffe8004b40, uris=0x0, launch_context=0x7fffe401c800, spawn_flags=G_SPAWN_SEARCH_PATH, user_setup=0, user_setup_data=0x0, pid_callback=0, pid_callback_data=0x0, error=0x7fffffffc848) at gdesktopappinfo.c:1269 5 0x00007ffff62e630a in g_desktop_app_info_launch_uris (appinfo=, uris=, launch_context=, error=) at gdesktopappinfo.c:1341 6 0x00007ffff62e636b in g_desktop_app_info_launch (appinfo=0x7fffe8004b40, files=, launch_context=0x7fffe401c800, error=0x7fffffffc848) at gdesktopappinfo.c:1388 --- gdk/x11/gdkapplaunchcontext-x11.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c index ff4f1cd18..825be753e 100644 --- a/gdk/x11/gdkapplaunchcontext-x11.c +++ b/gdk/x11/gdkapplaunchcontext-x11.c @@ -328,13 +328,15 @@ gdk_x11_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, if (icon == NULL) { icon = g_app_info_get_icon (info); - g_object_ref (icon); + if (icon != NULL) + g_object_ref (icon); } - if (icon) - icon_name = gicon_to_string (icon); - - g_object_unref (icon); + if (icon != NULL) + { + icon_name = gicon_to_string (icon); + g_object_unref (icon); + } } binary_name = g_app_info_get_executable (info); -- 2.43.2