[gnome-shell/wip/carlosg/check-systemd: 2/3] windowManager: Handle return value/errors from systemd unit calls



commit db96b52f391e2b4dc718a8c2e8b870ac4eb20460
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 7 11:15:46 2020 +0200

    windowManager: Handle return value/errors from systemd unit calls
    
    These may produce errors, and return a value indicating we should
    proceed further. Check for those when starting/stopping gsd-xsettings.

 js/ui/windowManager.js | 54 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 22 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index ffbec6d83c..14c914099f 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -900,35 +900,45 @@ var WindowManager = class {
 
         global.display.connect('init-xserver', (display, task) => {
             IBusManager.getIBusManager().restartDaemon(['--xim']);
-            Shell.util_start_systemd_unit('gsd-xsettings.target', 'fail');
-
-            /* Leave this watchdog timeout so don't block indefinitely here */
-            let timeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 5, () => {
-                Gio.DBus.session.unwatch_name(watchId);
-                log('Warning: Failed to start gsd-xsettings');
-                task.return_boolean(true);
-                timeoutId = 0;
-                return GLib.SOURCE_REMOVE;
-            });
 
-            /* When gsd-xsettings daemon is started, we are good to resume */
-            let watchId = Gio.DBus.session.watch_name(
-                'org.gnome.SettingsDaemon.XSettings',
-                Gio.BusNameWatcherFlags.NONE,
-                () => {
-                    Gio.DBus.session.unwatch_name(watchId);
-                    if (timeoutId > 0) {
+            try {
+                if (Shell.util_start_systemd_unit('gsd-xsettings.target', 'fail')) {
+                    /* Leave this watchdog timeout so don't block indefinitely here */
+                    let timeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 5, () => {
+                        Gio.DBus.session.unwatch_name(watchId);
+                        log('Warning: Failed to start gsd-xsettings');
                         task.return_boolean(true);
-                        GLib.source_remove(timeoutId);
-                    }
-                },
-                null);
+                        timeoutId = 0;
+                        return GLib.SOURCE_REMOVE;
+                    });
+
+                    /* When gsd-xsettings daemon is started, we are good to resume */
+                    let watchId = Gio.DBus.session.watch_name(
+                        'org.gnome.SettingsDaemon.XSettings',
+                        Gio.BusNameWatcherFlags.NONE,
+                        () => {
+                            Gio.DBus.session.unwatch_name(watchId);
+                            if (timeoutId > 0) {
+                                task.return_boolean(true);
+                                GLib.source_remove(timeoutId);
+                            }
+                        },
+                        null);
+                }
+            } catch (e) {
+                log('Error starting gsd-xsettings: %s'.format(e.message));
+            }
+
             return true;
         });
         global.display.connect('x11-display-closing', () => {
             if (!Meta.is_wayland_compositor())
                 return;
-            Shell.util_stop_systemd_unit('gsd-xsettings.target', 'fail');
+            try {
+                Shell.util_stop_systemd_unit('gsd-xsettings.target', 'fail');
+            } catch (e) {
+                log('Error stopping gsd-xsettings: %s'.format(e.message));
+            }
             IBusManager.getIBusManager().restartDaemon();
         });
 


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