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
This commit is contained in:
parent
760406002f
commit
5b3ff7184e
@ -115,13 +115,18 @@ function enableExtension(uuid) {
|
|||||||
extensionOrder.push(uuid);
|
extensionOrder.push(uuid);
|
||||||
|
|
||||||
let stylesheetNames = [global.session_mode + '.css', 'stylesheet.css'];
|
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++) {
|
for (let i = 0; i < stylesheetNames.length; i++) {
|
||||||
let stylesheetFile = extension.dir.get_child(stylesheetNames[i]);
|
try {
|
||||||
if (stylesheetFile.query_exists(null)) {
|
let stylesheetFile = extension.dir.get_child(stylesheetNames[i]);
|
||||||
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
|
|
||||||
theme.load_stylesheet(stylesheetFile);
|
theme.load_stylesheet(stylesheetFile);
|
||||||
extension.stylesheet = stylesheetFile;
|
extension.stylesheet = stylesheetFile;
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user