[gnome-settings-daemon/mcatanzaro/#585] usb-protection: don't crash when screensaver service is unavailable




commit 2e35d4d2673189e3d7517470fc500fdaca59d5e2
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Fri Sep 17 07:39:24 2021 -0500

    usb-protection: don't crash when screensaver service is unavailable
    
    gnome_settings_bus_get_screen_saver_proxy() can return NULL, e.g. when
    D-Bus is broken. We need to handle that case.
    
    Fixes #585

 plugins/usb-protection/gsd-usb-protection-manager.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/plugins/usb-protection/gsd-usb-protection-manager.c 
b/plugins/usb-protection/gsd-usb-protection-manager.c
index 92e0f097..1139696c 100644
--- a/plugins/usb-protection/gsd-usb-protection-manager.c
+++ b/plugins/usb-protection/gsd-usb-protection-manager.c
@@ -964,6 +964,12 @@ usb_protection_proxy_ready (GObject      *source_object,
                           G_CALLBACK (settings_changed_callback), manager);
 
         manager->screensaver_proxy = gnome_settings_bus_get_screen_saver_proxy ();
+        if (!manager->screensaver_proxy) {
+                if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+                        g_warning ("Failed to connect to screensaver service: %s", error->message);
+                g_clear_object (&manager->usb_protection);
+                return;
+        }
 
         get_current_screen_saver_status (manager);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]