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
commit 79433861fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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);