[gnome-shell] extensionPrefs: Always redefine getCurrentExtension() on prefsModule access



commit a2044c61ae0112f341e33891e7614883b80fb046
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Nov 30 19:15:14 2019 +0100

    extensionPrefs: Always redefine getCurrentExtension() on prefsModule access
    
    We have three interactions with an extension's prefs module:
     - we import the module
     - we call its init() hook
     - we call its buildPrefsWidget() hook
    
    The first two are one-time actions where we expect most getCurrentExtension()
    calls (local imports, initTranslations() etc.).
    
    However it's still possible that the extension will use the utility function
    in buildPrefsWidget() as well, either directly or via other functions like
    getSettings(): Make sure getCurrentExtension() returns the correct extension
    in that case, not the last one whose preferences were initialized.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/873

 js/extensionPrefs/main.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 387f7f325b..9d94c5a27a 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -657,12 +657,12 @@ class ExtensionRow extends Gtk.ListBoxRow {
     }
 
     get prefsModule() {
+        // give extension prefs access to their own extension object
+        ExtensionUtils.getCurrentExtension = () => this._extension;
+
         if (!this._prefsModule) {
             ExtensionUtils.installImporter(this._extension);
 
-            // give extension prefs access to their own extension object
-            ExtensionUtils.getCurrentExtension = () => this._extension;
-
             this._prefsModule = this._extension.imports.prefs;
             this._prefsModule.init(this._extension.metadata);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]