Last Comment Bug 714132 - Possible double release of a NSColor
: Possible double release of a NSColor
Status: RESOLVED FIXED
[inbound]
:
Product: Core
Classification: Components
Component: Widget: Cocoa (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal (vote)
: mozilla12
Assigned To: Hubert Figuiere [:hub]
:
: Markus Stange [:mstange]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-29 11:50 PST by Hubert Figuiere [:hub]
Modified: 2012-01-04 17:28 PST (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
[NSColor whiteColor] must be retained in ToolbarWindow. r= (1.20 KB, patch)
2011-12-29 12:01 PST, Hubert Figuiere [:hub]
smichaud: review+
smichaud: checkin+
Details | Diff | Splinter Review

Description Hubert Figuiere [:hub] 2011-12-29 11:50:27 PST
in nsCocoaWindow.mm around line 2318
in the method -[ToolbarWindow initWithContentRect:...], we do mBackgroundColor = [NSColor whiteColor]. but in the dealloc, we do [mBackgroundColor release] which leads so do we in -[ToolbarWindow setBackgroundColor:].

[NSColor whiteColor] returns an "autoreleased", therefor we should retain it.

The fact that it does not crash is surprising, albeit maybe not as it is entirely possible that the framework returns a static instance. But this is implementation dependent.

Will attach a patch.
Comment 1 Hubert Figuiere [:hub] 2011-12-29 12:01:49 PST
Created attachment 584805 [details] [diff] [review]
[NSColor whiteColor] must be retained in ToolbarWindow. r=
Comment 2 Steven Michaud [:smichaud] (Retired) 2012-01-04 07:56:26 PST
Comment on attachment 584805 [details] [diff] [review]
[NSColor whiteColor] must be retained in ToolbarWindow. r=

I also don't know why we don't crash, but this is the right thing to do.
Comment 3 Steven Michaud [:smichaud] (Retired) 2012-01-04 11:58:38 PST
Comment on attachment 584805 [details] [diff] [review]
[NSColor whiteColor] must be retained in ToolbarWindow. r=

Landed on mozilla-inbound:
http://hg.mozilla.org/integration/mozilla-inbound/rev/0022f8be9fea
Comment 4 Ed Morley [:emorley] 2012-01-04 17:28:40 PST
https://hg.mozilla.org/mozilla-central/rev/0022f8be9fea

Note You need to log in before you can comment on or make changes to this bug.