Extension rebasing assumes that no modifications occur during run-time. Banning run-time/optional overrides to avoid this, as suggested by @fmuellner
, would be too limiting, as pointed by @JustPerfection
I think, further discussion about extension conflict avoidance should move here since the original post was about partially disabling.
InjectionTracker
Potentially, the way I have worked around this problem could be of help.
I wanted two of my extensions to hook into Main.panel.statusArea.quickSettings._addItemsBefore
and then restore the original method during run-time.
To achieve this without conflicts during restore, I implemented an InjectionTracker
which keeps track of the override history.
- The history for each overridden method/property is stored as an array of property descriptors in an dictionary
Main.panel.statusArea.quickSettings.__injectionHistories
. - When overriding a method by calling
injectProperty
, an injection handleinj
is returned which can be used to call the previous injectioninj.previous.call(...)
or the original methodinj.original.call(...)
.
const injection = this.tracker.injectProperty(
qs, '_addItemsBefore',
(...args) => {
this._setup(qs);
injection.clear();
injection.previous.call(qs, ...args);
}
);
- If all injections have been
inj.clear()
ed, the original method gets restored and the history dictionary removed fromMain.panel.statusArea.quickSettings.__injectionHistories
.
If extensions use the InjectionTracker
instead of the InjectionManager
, conflicts due to run-time method overrides could be mitigated.
However, conflicts due to adding and removing widgets during run-time can occur nonetheless.