diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-08-22 21:52:27 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-11-14 10:52:46 +0100 |
commit | 799489262253e8d622ce4c72572f0d48afeb238d (patch) | |
tree | 278ebd2e310e507e2f22e3ceff771c764a5c6e06 /demo | |
parent | ea52170f62da6cbdb8b5ff093c75cb639df9f11d (diff) | |
download | geoclue-799489262253e8d622ce4c72572f0d48afeb238d.tar.gz |
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.
Diffstat (limited to 'demo')
-rw-r--r-- | demo/where-am-i.c | 22 |
1 files changed, 12 insertions, 10 deletions
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 |