From 799489262253e8d622ce4c72572f0d48afeb238d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 22 Aug 2018 21:52:27 -0400 Subject: where-am-I: Handle gclue_simple_get_client returning NULL The incoming portal support will provide an implementation for GClueSimple that is not based on GClueClient, and gclue_simple_get_client will return NULL then. No need to crash in that case. --- demo/where-am-i.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'demo') diff --git a/demo/where-am-i.c b/demo/where-am-i.c index 5934161..eff5ed6 100644 --- a/demo/where-am-i.c +++ b/demo/where-am-i.c @@ -152,23 +152,25 @@ on_simple_ready (GObject *source_object, exit (-1); } client = gclue_simple_get_client (simple); - g_object_ref (client); - g_print ("Client object: %s\n", - g_dbus_proxy_get_object_path (G_DBUS_PROXY (client))); - if (time_threshold > 0) { - gclue_client_set_time_threshold (client, time_threshold); + if (client) { + g_object_ref (client); + g_print ("Client object: %s\n", + g_dbus_proxy_get_object_path (G_DBUS_PROXY (client))); + if (time_threshold > 0) { + gclue_client_set_time_threshold (client, time_threshold); + } + + g_signal_connect (client, + "notify::active", + G_CALLBACK (on_client_active_notify), + NULL); } - print_location (simple); g_signal_connect (simple, "notify::location", G_CALLBACK (print_location), NULL); - g_signal_connect (client, - "notify::active", - G_CALLBACK (on_client_active_notify), - NULL); } gint -- cgit v1.2.1