Bug 1348424 - Grab a reference to the window when swapping out its background color. r=spohl, a=gchang
authorMarkus Stange <mstange@themasta.com>
Thu, 23 Mar 2017 14:29:51 -0400
changeset 396148 21bcd10f1a108706b8b7bafcddeb71edca037488
parent 396147 e664fb8bf2fd8f686c73cb61cdd58c0b16d4d739
child 396149 af52afddd195175dfcff1d3fe20be04f796898c7
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, gchang
bugs1348424
milestone54.0
Bug 1348424 - Grab a reference to the window when swapping out its background color. r=spohl, a=gchang MozReview-Commit-ID: HS1AYyxfMWS
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2988,31 +2988,32 @@ nsChildView::DispatchAPZWheelInputEvent(
 //
 // So we set temporary color that is NSColor before calling it.
 
 class MOZ_RAII AutoBackgroundSetter final {
 public:
   explicit AutoBackgroundSetter(NSView* aView) {
     if (nsCocoaFeatures::OnElCapitanOrLater() &&
         [[aView window] isKindOfClass:[ToolbarWindow class]]) {
-      mWindow = (ToolbarWindow*)[aView window];
+      mWindow = [(ToolbarWindow*)[aView window] retain];
       [mWindow setTemporaryBackgroundColor];
     } else {
       mWindow = nullptr;
     }
   }
 
   ~AutoBackgroundSetter() {
     if (mWindow) {
       [mWindow restoreBackgroundColor];
+      [mWindow release];
     }
   }
 
 private:
-  ToolbarWindow* mWindow;
+  ToolbarWindow* mWindow; // strong
 };
 
 void
 nsChildView::LookUpDictionary(
                const nsAString& aText,
                const nsTArray<mozilla::FontRange>& aFontRangeArray,
                const bool aIsVertical,
                const LayoutDeviceIntPoint& aPoint)