mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 797065 - Leak if I quit while Scratchpad is open. r=dcamp
This commit is contained in:
parent
3a740f52c0
commit
20e32c7b31
@ -69,11 +69,29 @@ this.ScratchpadManager = {
|
||||
saveOpenWindows: function SPM_saveOpenWindows() {
|
||||
this._scratchpads = [];
|
||||
|
||||
function clone(src) {
|
||||
let dest = {};
|
||||
|
||||
for (let key in src) {
|
||||
if (src.hasOwnProperty(key)) {
|
||||
dest[key] = src[key];
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
// We need to clone objects we get from Scratchpad instances
|
||||
// because such (cross-window) objects have a property 'parent'
|
||||
// that holds on to a ChromeWindow instance. This means that
|
||||
// such objects are not primitive-values-only anymore so they
|
||||
// can leak.
|
||||
|
||||
let enumerator = Services.wm.getEnumerator("devtools:scratchpad");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let win = enumerator.getNext();
|
||||
if (!win.closed && win.Scratchpad.initialized) {
|
||||
this._scratchpads.push(win.Scratchpad.getState());
|
||||
this._scratchpads.push(clone(win.Scratchpad.getState()));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -106,6 +124,7 @@ this.ScratchpadManager = {
|
||||
|
||||
let win = Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
|
||||
SCRATCHPAD_WINDOW_FEATURES, params);
|
||||
|
||||
// Only add the shutdown observer if we've opened a scratchpad window.
|
||||
ShutdownObserver.init();
|
||||
|
||||
@ -128,6 +147,7 @@ var ShutdownObserver = {
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
|
||||
this._initialized = true;
|
||||
},
|
||||
|
||||
@ -143,4 +163,4 @@ var ShutdownObserver = {
|
||||
{
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
}
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user