catch more errors on extensions enable() and disable()
https://bugzilla.gnome.org/show_bug.cgi?id=688331
This commit is contained in:
parent
f3b7f61e54
commit
2c538d247b
@ -76,7 +76,11 @@ function disableExtension(uuid) {
|
|||||||
theme.unload_stylesheet(extension.stylesheet.get_path());
|
theme.unload_stylesheet(extension.stylesheet.get_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.stateObj.disable();
|
try {
|
||||||
|
extension.stateObj.disable();
|
||||||
|
} catch(e) {
|
||||||
|
logExtensionError(uuid, e);
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < order.length; i++) {
|
for (let i = 0; i < order.length; i++) {
|
||||||
let uuid = order[i];
|
let uuid = order[i];
|
||||||
@ -89,8 +93,10 @@ function disableExtension(uuid) {
|
|||||||
|
|
||||||
extensionOrder.splice(orderIdx, 1);
|
extensionOrder.splice(orderIdx, 1);
|
||||||
|
|
||||||
extension.state = ExtensionState.DISABLED;
|
if ( extension.state != ExtensionState.ERROR ) {
|
||||||
_signals.emit('extension-state-changed', extension);
|
extension.state = ExtensionState.DISABLED;
|
||||||
|
_signals.emit('extension-state-changed', extension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableExtension(uuid) {
|
function enableExtension(uuid) {
|
||||||
@ -117,10 +123,15 @@ function enableExtension(uuid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.stateObj.enable();
|
try {
|
||||||
|
extension.stateObj.enable();
|
||||||
extension.state = ExtensionState.ENABLED;
|
extension.state = ExtensionState.ENABLED;
|
||||||
_signals.emit('extension-state-changed', extension);
|
_signals.emit('extension-state-changed', extension);
|
||||||
|
return;
|
||||||
|
} catch(e) {
|
||||||
|
logExtensionError(uuid, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function logExtensionError(uuid, error) {
|
function logExtensionError(uuid, error) {
|
||||||
@ -150,7 +161,8 @@ function loadExtension(extension) {
|
|||||||
} else {
|
} else {
|
||||||
let enabled = enabledExtensions.indexOf(extension.uuid) != -1;
|
let enabled = enabledExtensions.indexOf(extension.uuid) != -1;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
initExtension(extension.uuid);
|
if (!initExtension(extension.uuid))
|
||||||
|
return;
|
||||||
if (extension.state == ExtensionState.DISABLED)
|
if (extension.state == ExtensionState.DISABLED)
|
||||||
enableExtension(extension.uuid);
|
enableExtension(extension.uuid);
|
||||||
} else {
|
} else {
|
||||||
@ -205,7 +217,12 @@ function initExtension(uuid) {
|
|||||||
extensionModule = extension.imports.extension;
|
extensionModule = extension.imports.extension;
|
||||||
|
|
||||||
if (extensionModule.init) {
|
if (extensionModule.init) {
|
||||||
extensionState = extensionModule.init(extension);
|
try {
|
||||||
|
extensionState = extensionModule.init(extension);
|
||||||
|
} catch(e) {
|
||||||
|
logExtensionError(uuid, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extensionState)
|
if (!extensionState)
|
||||||
@ -214,6 +231,7 @@ function initExtension(uuid) {
|
|||||||
|
|
||||||
extension.state = ExtensionState.DISABLED;
|
extension.state = ExtensionState.DISABLED;
|
||||||
_signals.emit('extension-loaded', uuid);
|
_signals.emit('extension-loaded', uuid);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnabledExtensions() {
|
function getEnabledExtensions() {
|
||||||
@ -235,11 +253,7 @@ function onEnabledExtensionsChanged() {
|
|||||||
newEnabledExtensions.filter(function(uuid) {
|
newEnabledExtensions.filter(function(uuid) {
|
||||||
return enabledExtensions.indexOf(uuid) == -1;
|
return enabledExtensions.indexOf(uuid) == -1;
|
||||||
}).forEach(function(uuid) {
|
}).forEach(function(uuid) {
|
||||||
try {
|
|
||||||
enableExtension(uuid);
|
enableExtension(uuid);
|
||||||
} catch(e) {
|
|
||||||
logExtensionError(uuid, e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find and disable all the newly disabled extensions: UUIDs found in the
|
// Find and disable all the newly disabled extensions: UUIDs found in the
|
||||||
@ -247,11 +261,7 @@ function onEnabledExtensionsChanged() {
|
|||||||
enabledExtensions.filter(function(item) {
|
enabledExtensions.filter(function(item) {
|
||||||
return newEnabledExtensions.indexOf(item) == -1;
|
return newEnabledExtensions.indexOf(item) == -1;
|
||||||
}).forEach(function(uuid) {
|
}).forEach(function(uuid) {
|
||||||
try {
|
|
||||||
disableExtension(uuid);
|
disableExtension(uuid);
|
||||||
} catch(e) {
|
|
||||||
logExtensionError(uuid, e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
enabledExtensions = newEnabledExtensions;
|
enabledExtensions = newEnabledExtensions;
|
||||||
@ -263,11 +273,7 @@ function _loadExtensions() {
|
|||||||
|
|
||||||
let finder = new ExtensionUtils.ExtensionFinder();
|
let finder = new ExtensionUtils.ExtensionFinder();
|
||||||
finder.connect('extension-found', function(signals, extension) {
|
finder.connect('extension-found', function(signals, extension) {
|
||||||
try {
|
loadExtension(extension);
|
||||||
loadExtension(extension);
|
|
||||||
} catch(e) {
|
|
||||||
logExtensionError(extension.uuid, e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
finder.scanExtensions();
|
finder.scanExtensions();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user