extensionSystem: fix runtime enable()/disable() after last changes
disableExtension still used the old way to retrieve the state object, and enableExtension called loadExtension at a time that would always fail. https://bugzilla.gnome.org/show_bug.cgi?id=669694
This commit is contained in:
parent
aa2a63bd84
commit
d0cd6ba47d
@ -163,8 +163,6 @@ function disableExtension(uuid) {
|
|||||||
if (extension.state != ExtensionState.ENABLED)
|
if (extension.state != ExtensionState.ENABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let extensionState = extensionStateObjs[uuid];
|
|
||||||
|
|
||||||
// "Rebase" the extension order by disabling and then enabling extensions
|
// "Rebase" the extension order by disabling and then enabling extensions
|
||||||
// in order to help prevent conflicts.
|
// in order to help prevent conflicts.
|
||||||
|
|
||||||
@ -180,14 +178,14 @@ function disableExtension(uuid) {
|
|||||||
for (let i = 0; i < orderReversed.length; i++) {
|
for (let i = 0; i < orderReversed.length; i++) {
|
||||||
let uuid = orderReversed[i];
|
let uuid = orderReversed[i];
|
||||||
try {
|
try {
|
||||||
extensionStateObjs[uuid].disable();
|
ExtensionUtils.extensions[uuid].stateObj.disable();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logExtensionError(uuid, e.toString());
|
logExtensionError(uuid, e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
extensionState.disable();
|
extension.stateObj.disable();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logExtensionError(uuid, e.toString());
|
logExtensionError(uuid, e.toString());
|
||||||
return;
|
return;
|
||||||
@ -196,7 +194,7 @@ function disableExtension(uuid) {
|
|||||||
for (let i = 0; i < order.length; i++) {
|
for (let i = 0; i < order.length; i++) {
|
||||||
let uuid = order[i];
|
let uuid = order[i];
|
||||||
try {
|
try {
|
||||||
extensionStateObjs[uuid].enable();
|
ExtensionUtils.extensions[uuid].stateObj.enable();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logExtensionError(uuid, e.toString());
|
logExtensionError(uuid, e.toString());
|
||||||
}
|
}
|
||||||
@ -213,10 +211,8 @@ function enableExtension(uuid) {
|
|||||||
if (!extension)
|
if (!extension)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (extension.state == ExtensionState.INITIALIZED) {
|
if (extension.state == ExtensionState.INITIALIZED)
|
||||||
loadExtension(extension.dir, extension.type, true);
|
initExtension(uuid);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension.state != ExtensionState.DISABLED)
|
if (extension.state != ExtensionState.DISABLED)
|
||||||
return;
|
return;
|
||||||
@ -274,11 +270,25 @@ function loadExtension(dir, type, enabled) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled) {
|
if (enabled) {
|
||||||
|
initExtension(uuid);
|
||||||
|
if (extension.state == ExtensionState.DISABLED)
|
||||||
|
enableExtension(uuid);
|
||||||
|
} else {
|
||||||
extension.state = ExtensionState.INITIALIZED;
|
extension.state = ExtensionState.INITIALIZED;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_signals.emit('extension-state-changed', extension);
|
||||||
|
global.log('Loaded extension ' + uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initExtension(uuid) {
|
||||||
|
let extension = ExtensionUtils.extensions[uuid];
|
||||||
|
let dir = extension.dir;
|
||||||
|
|
||||||
|
if (!extension)
|
||||||
|
throw new Error("Extension was not properly created. Call loadExtension first");
|
||||||
|
|
||||||
let extensionJs = dir.get_child('extension.js');
|
let extensionJs = dir.get_child('extension.js');
|
||||||
if (!extensionJs.query_exists(null)) {
|
if (!extensionJs.query_exists(null)) {
|
||||||
logExtensionError(uuid, 'Missing extension.js');
|
logExtensionError(uuid, 'Missing extension.js');
|
||||||
@ -338,11 +348,7 @@ function loadExtension(dir, type, enabled) {
|
|||||||
|
|
||||||
extension.state = ExtensionState.DISABLED;
|
extension.state = ExtensionState.DISABLED;
|
||||||
|
|
||||||
enableExtension(uuid);
|
|
||||||
|
|
||||||
_signals.emit('extension-loaded', uuid);
|
_signals.emit('extension-loaded', uuid);
|
||||||
_signals.emit('extension-state-changed', extension);
|
|
||||||
global.log('Loaded extension ' + uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEnabledExtensionsChanged() {
|
function onEnabledExtensionsChanged() {
|
||||||
|
Loading…
Reference in New Issue
Block a user