fix: BrowserWindow add the same BrowserView (#48201)

fix: BrowserWindow add the same BrowserView (#48057)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Zonglong Liu <83216456+mai-121@users.noreply.github.com>
This commit is contained in:
trop[bot]
2025-09-02 16:56:04 -04:00
committed by GitHub
parent a7335142a4
commit 79433861fe
2 changed files with 41 additions and 1 deletions

View File

@@ -199,7 +199,14 @@ BrowserWindow.prototype.setBackgroundThrottling = function (allowed: boolean) {
};
BrowserWindow.prototype.addBrowserView = function (browserView: BrowserView) {
if (browserView.ownerWindow) { browserView.ownerWindow.removeBrowserView(browserView); }
if (this._browserViews.includes(browserView)) {
return;
}
const ownerWindow = browserView.ownerWindow;
if (ownerWindow && ownerWindow !== this) {
ownerWindow.removeBrowserView(browserView);
}
this.contentView.addChildView(browserView.webContentsView);
browserView.ownerWindow = this;
browserView.webContents._setOwnerWindow(this);