From fd5f67d2e3459168f9cf83648d5f7f91eccca61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 14 Jun 2018 17:43:27 +0200 Subject: [PATCH] idle-monitor: NULL check cached InhibitedActions property variant We might not have a cached "InhibitedActions" property available for us, so do as elsewhere in this file and NULL check before processing it. https://gitlab.gnome.org/GNOME/mutter/merge_requests/130 --- src/backends/meta-idle-monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c index c6e814468..6ce024001 100644 --- a/src/backends/meta-idle-monitor.c +++ b/src/backends/meta-idle-monitor.c @@ -235,62 +235,65 @@ meta_idle_monitor_inhibited_actions_changed (GDBusProxy *session, } } static void meta_idle_monitor_init (MetaIdleMonitor *monitor) { GVariant *v; monitor->watches = g_hash_table_new_full (NULL, NULL, NULL, free_watch); monitor->last_event_time = g_get_monotonic_time (); /* Monitor inhibitors */ monitor->session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, NULL, "org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager", NULL, NULL); if (!monitor->session_proxy) return; g_signal_connect (monitor->session_proxy, "g-properties-changed", G_CALLBACK (meta_idle_monitor_inhibited_actions_changed), monitor); v = g_dbus_proxy_get_cached_property (monitor->session_proxy, "InhibitedActions"); - monitor->inhibited = g_variant_get_uint32 (v) & GSM_INHIBITOR_FLAG_IDLE; - g_variant_unref (v); + if (v) + { + monitor->inhibited = g_variant_get_uint32 (v) & GSM_INHIBITOR_FLAG_IDLE; + g_variant_unref (v); + } } /** * meta_idle_monitor_get_core: * * Returns: (transfer none): the #MetaIdleMonitor that tracks the server-global * idletime for all devices. To track device-specific idletime, * use meta_idle_monitor_get_for_device(). */ MetaIdleMonitor * meta_idle_monitor_get_core (void) { MetaBackend *backend = meta_get_backend (); return meta_backend_get_idle_monitor (backend, 0); } /** * meta_idle_monitor_get_for_device: * @device_id: the device to get the idle time for. * * Returns: (transfer none): a new #MetaIdleMonitor that tracks the * device-specific idletime for @device. To track server-global idletime * for all devices, use meta_idle_monitor_get_core(). */ MetaIdleMonitor * meta_idle_monitor_get_for_device (int device_id) { MetaBackend *backend = meta_get_backend (); return meta_backend_get_idle_monitor (backend, device_id); } -- 2.28.0