From 73649a0d6ab1775c3423d9b7793c0cc4c0e0aef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 3 Aug 2018 15:46:27 +0000 Subject: [PATCH] extensionSystem: Don't load an extension with invalid stylesheet We currently assign the stylesheet to an extension whenever the file exists, regardless of whether it actually loaded successfully or not. And thus we load an extension that ships a stylesheet even if that file can't be used. There is no point in trying to load an extension if its stylesheet wasn't loaded in the first place, so make sure this happens only on success. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/188 (cherry picked from commit 5b3ff7184eab6c128528a7cdc7b42b2636a6d022) --- js/ui/extensionSystem.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index e35c01ab8..3f23d273e 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -115,13 +115,18 @@ function enableExtension(uuid) { extensionOrder.push(uuid); let stylesheetNames = [global.session_mode + '.css', 'stylesheet.css']; + let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); for (let i = 0; i < stylesheetNames.length; i++) { - let stylesheetFile = extension.dir.get_child(stylesheetNames[i]); - if (stylesheetFile.query_exists(null)) { - let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); + try { + let stylesheetFile = extension.dir.get_child(stylesheetNames[i]); theme.load_stylesheet(stylesheetFile); extension.stylesheet = stylesheetFile; break; + } catch (e) { + if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) + continue; // not an error + log(`Failed to load stylesheet for extension ${uuid}: ${e.message}`); + return; } }