From 7af37215e3cfe1b0d189b076333f29e6a7a37b82 Mon Sep 17 00:00:00 2001 From: flexagoon Date: Fri, 3 May 2024 07:19:00 +0300 Subject: [PATCH] fix: don't restore patched prototypes when suspending Patched prototypes should only be restored in the disable() method of the extension, since gnome enforces extension rebasing when disabling them. Restoring protos in any other place may lead to infinite recursion if a different extension is also patching the same function. See https://gitlab.gnome.org/ewlsh/gjs-guide/-/issues/75 https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7629 Fixes: #585 --- src/components/overview.js | 22 +++++++++++++--------- src/extension.js | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/overview.js b/src/components/overview.js index b09dcda1..13992343 100644 --- a/src/components/overview.js +++ b/src/components/overview.js @@ -27,6 +27,7 @@ export const OverviewBlur = class OverviewBlur { { name: 'bms-animation-backgroundgroup' } ); this.enabled = false; + this.proto_patched = false; } enable() { @@ -48,9 +49,9 @@ export const OverviewBlur = class OverviewBlur { // part for the workspace animation switch - // make sure not to do this part if the extension was enabled prior, as + // make sure not to do this part if the functions were patched prior, as // the functions would call themselves and cause infinite recursion - if (!this.enabled) { + if (!this.proto_patched) { // store original workspace switching methods for restoring them on // disable() this._original_PrepareSwitch = wac_proto._prepareWorkspaceSwitch; @@ -113,6 +114,8 @@ export const OverviewBlur = class OverviewBlur { Main.uiGroup.remove_child(outer_this.animation_background_group); }; + + this.proto_patched = true; } this.enabled = true; @@ -184,18 +187,19 @@ export const OverviewBlur = class OverviewBlur { style => Main.uiGroup.remove_style_class_name(style) ); - // make sure to absolutely not do this if the component was not enabled - // prior, as this would cause infinite recursion - if (this.enabled) { - // restore original behavior + this.connections.disconnect_all(); + this.enabled = false; + } + + restore_patched_proto() { + if (this.proto_patched) { if (this._original_PrepareSwitch) wac_proto._prepareWorkspaceSwitch = this._original_PrepareSwitch; if (this._original_FinishSwitch) wac_proto._finishWorkspaceSwitch = this._original_FinishSwitch; - } - this.connections.disconnect_all(); - this.enabled = false; + this.proto_patched = false; + } } _log(str) { diff --git a/src/extension.js b/src/extension.js index d789eb2f..99990a34 100644 --- a/src/extension.js +++ b/src/extension.js @@ -155,6 +155,7 @@ export default class BlurMyShell extends Extension { // disable every component from user session mode if (this._user_session_mode_enabled) this._disable_user_session(); + this._overview_blur.restore_patched_proto(); // disable lockscreen blur too this._lockscreen_blur.disable();