tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 6bad472d648665b6e0f84d7c981f718a16c4bd10
parent 21ba2b46059a651265ddd1904b1dce0be02e04f7
Author: Brad Werth <werth@efn.org>
Date:   Wed, 26 Nov 2025 15:24:58 +0000

Bug 1972888 Part 2: Ensure that nsCocoaWindow::mWindow is never returned as an unretained reference. r=mac-reviewers,mstange

This will hopefully fix the original issue of Bug 1880582, where the
native window was being manipulated without it having been retained.

Differential Revision: https://phabricator.services.mozilla.com/D272527

Diffstat:
Mwidget/cocoa/nsCocoaWindow.h | 2+-
Mwidget/cocoa/nsCocoaWindow.mm | 4++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h @@ -464,7 +464,7 @@ class nsCocoaWindow final : public nsIWidget { bool HasModalDescendants() const { return mNumModalDescendants > 0; } bool IsModal() const { return mModal; } - NSWindow* GetCocoaWindow() { return mWindow; } + NSWindow* GetCocoaWindow() { return [[mWindow retain] autorelease]; } void SetMenuBar(RefPtr<nsMenuBarX>&& aMenuBar); nsMenuBarX* GetMenuBar(); diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm @@ -5056,11 +5056,11 @@ void* nsCocoaWindow::GetNativeData(uint32_t aDataType) { // to emulate how windows works, we always have to return a NSView // for NS_NATIVE_WIDGET case NS_NATIVE_WIDGET: - retVal = mChildView; + retVal = [[mChildView retain] autorelease]; break; case NS_NATIVE_WINDOW: - retVal = mWindow; + retVal = [[mWindow retain] autorelease]; break; case NS_NATIVE_GRAPHIC: