diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index de68cfe83fa2..c000be277e32 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -770,8 +770,9 @@ NS_IMETHODIMP nsCocoaWindow::Show(bool bState) [NSApp endSheet:nativeParentWindow]; } - nsCocoaWindow* sheetShown = nullptr; - if (NS_SUCCEEDED(piParentWidget->GetChildSheet(true, &sheetShown)) && + nsCOMPtr sheetShown; + if (NS_SUCCEEDED(piParentWidget->GetChildSheet( + true, getter_AddRefs(sheetShown))) && (!sheetShown || sheetShown == this)) { // If this sheet is already the sheet actually being shown, don't // tell it to show again. Otherwise the number of calls to @@ -888,11 +889,12 @@ NS_IMETHODIMP nsCocoaWindow::Show(bool bState) [TopLevelWindowData deactivateInWindow:mWindow]; - nsCocoaWindow* siblingSheetToShow = nullptr; + nsCOMPtr siblingSheetToShow; bool parentIsSheet = false; if (nativeParentWindow && piParentWidget && - NS_SUCCEEDED(piParentWidget->GetChildSheet(false, &siblingSheetToShow)) && + NS_SUCCEEDED(piParentWidget->GetChildSheet( + false, getter_AddRefs(siblingSheetToShow))) && siblingSheetToShow) { // First, give sibling sheets an opportunity to show. siblingSheetToShow->Show(true); @@ -1842,7 +1844,7 @@ NS_IMETHODIMP nsCocoaWindow::SendSetZLevelEvent() return NS_OK; } -NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsCocoaWindow** _retval) +NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsIWidget** _retval) { nsIWidget* child = GetFirstChild(); @@ -1853,7 +1855,8 @@ NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsCocoaWindow** _retval) if (cocoaWindow->mWindow && ((aShown && [cocoaWindow->mWindow isVisible]) || (!aShown && cocoaWindow->mSheetNeedsShow))) { - *_retval = cocoaWindow; + nsCOMPtr widget = cocoaWindow; + widget.forget(_retval); return NS_OK; } } diff --git a/widget/cocoa/nsPIWidgetCocoa.idl b/widget/cocoa/nsPIWidgetCocoa.idl index 8e1f9e08cb88..a8fd8149ce5a 100644 --- a/widget/cocoa/nsPIWidgetCocoa.idl +++ b/widget/cocoa/nsPIWidgetCocoa.idl @@ -5,8 +5,6 @@ #include "nsISupports.idl" -interface nsMenuBarX; -interface nsCocoaWindow; interface nsIWidget; [ptr] native NSWindowPtr(NSWindow); @@ -24,7 +22,7 @@ interface nsPIWidgetCocoa : nsISupports // Find the displayed child sheet (if aShown) or a child sheet that // wants to be displayed (if !aShown) - nsCocoaWindow GetChildSheet(in boolean aShown); + nsIWidget GetChildSheet(in boolean aShown); // Get the parent widget (if any) StandardCreate() was called with. nsIWidget GetRealParent();