mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-29 03:41:51 +00:00
fix: Fixed race condition happening when moving tabs to a synced window, b=closes #12707, c=common
This commit is contained in:
@@ -11,6 +11,9 @@ class ZenStartup {
|
||||
#hasInitializedLayout = false;
|
||||
|
||||
isReady = false;
|
||||
promiseInitialized = new Promise(resolve => {
|
||||
this.promiseInitializedResolve = resolve;
|
||||
});
|
||||
|
||||
init() {
|
||||
this.openWatermark();
|
||||
@@ -94,6 +97,8 @@ class ZenStartup {
|
||||
.getElementById("tabbrowser-arrowscrollbox")
|
||||
.setAttribute("orient", "vertical");
|
||||
this.isReady = true;
|
||||
this.promiseInitializedResolve();
|
||||
delete this.promiseInitializedResolve;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -810,11 +810,18 @@ class nsZenWindowSync {
|
||||
aOtherTab,
|
||||
() => {
|
||||
this.log(`Swapping docshells between windows for tab ${aOurTab.id}`);
|
||||
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(
|
||||
aOurTab,
|
||||
aOtherTab,
|
||||
false
|
||||
);
|
||||
try {
|
||||
aOurTab.ownerGlobal.gBrowser.swapBrowsersAndCloseOther(
|
||||
aOurTab,
|
||||
aOtherTab,
|
||||
false
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Error swapping browsers for tabs ${aOurTab.id} and ${aOtherTab.id}:`,
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
// Swap permanent keys
|
||||
if (!onClose) {
|
||||
@@ -1221,9 +1228,15 @@ class nsZenWindowSync {
|
||||
{},
|
||||
/* zenForceSync = */ true
|
||||
);
|
||||
win.gZenWorkspaces.promiseInitialized.then(() => {
|
||||
moveAllTabsToWindow();
|
||||
});
|
||||
win.addEventListener(
|
||||
"MozBeforeInitialXULLayout",
|
||||
() => {
|
||||
win.gZenStartup.promiseInitialized.then(() => {
|
||||
moveAllTabsToWindow();
|
||||
});
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
return;
|
||||
}
|
||||
moveAllTabsToWindow(true);
|
||||
|
||||
Reference in New Issue
Block a user