[gnome-shell] extensionSystem: Rebase the extension order list to help prevent conflicts
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensionSystem: Rebase the extension order list to help prevent conflicts
- Date: Thu, 20 Oct 2011 21:38:58 +0000 (UTC)
commit fd1b3b4fee271108794ca4150c84cce7e56a6243
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Oct 14 18:06:03 2011 -0400
extensionSystem: Rebase the extension order list to help prevent conflicts
When two extensions monkey-patch the same area, enable() and disable() may
behave badly and completely wreck things. To solve this, when disabling
an extension, "rebase" the extension list so that monkey patches should be
added and removed in order.
https://bugzilla.gnome.org/show_bug.cgi?id=661815
js/ui/extensionSystem.js | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index c30da01..95c3a29 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -64,6 +64,8 @@ const extensions = {};
const extensionStateObjs = {};
// Maps uuid -> [GFile to the extension directory, Extension type]
const extensionDirs = {};
+// Contains the order that extensions were enabled in.
+const extensionOrder = [];
// Arrays of uuids
var enabledExtensions;
@@ -215,6 +217,27 @@ function disableExtension(uuid) {
let extensionState = extensionStateObjs[uuid];
+ // "Rebase" the extension order by disabling and then enabling extensions
+ // in order to help prevent conflicts.
+
+ // Example:
+ // order = [A, B, C, D, E]
+ // user disables C
+ // this should: disable E, disable D, disable C, enable D, enable E
+
+ let orderIdx = extensionOrder.indexOf(uuid);
+ let order = extensionOrder.slice(orderIdx + 1);
+ let orderReversed = order.slice().reverse();
+
+ for (let i = 0; i < orderReversed.length; i++) {
+ let uuid = orderReversed[i];
+ try {
+ extensionStateObjs[uuid].disable();
+ } catch(e) {
+ logExtensionError(uuid, e.toString());
+ }
+ }
+
try {
extensionState.disable();
} catch(e) {
@@ -222,6 +245,15 @@ function disableExtension(uuid) {
return;
}
+ for (let i = 0; i < order.length; i++) {
+ let uuid = order[i];
+ try {
+ extensionStateObjs[uuid].enable();
+ } catch(e) {
+ logExtensionError(uuid, e.toString());
+ }
+ }
+
meta.state = ExtensionState.DISABLED;
_signals.emit('extension-state-changed', meta);
}
@@ -241,6 +273,8 @@ function enableExtension(uuid) {
let extensionState = extensionStateObjs[uuid];
+ extensionOrder.push(uuid);
+
try {
extensionState.enable();
} catch(e) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]