This code is supposed to (according to the comments) look for Safari window,
"harmlessly" to
other browsers.
NSWindow* cocoaWindow = [[NSWindow alloc] initWithWindowRef:theWindow];
if (cocoaWindow) {
if (strcmp(object_getClassName(cocoaWindow), "BrowserWindow") == 0) {
return cocoaWindow;
} else {
[cocoaWindow release];
}
}
The problem is that it actually destroys any non-Safari window it operates on.
The docs for initWithWindowRef: say that it does *not* retain windowRef, but
*does* release it on de-alloc, so
the NSWindow takes ownership of one retain on the window ref. If the window ref
given to this
method isn't a BrowserWindow, the net effect is to immediately decrement the
release count of
the window.
It should CFRetain the windowRef if cocoaWindow is non-nil, to balance the
release. (I'm not sure
if the it-is-a-BrowserWindow path should CFRelease or not; it seems unlikely if
the windowRef
originally comes in through NPAPI)
Original issue reported on code.google.com by stuartmorgan@chromium.org on 10 Dec 2009 at 8:19
Original issue reported on code.google.com by
stuartmorgan@chromium.org
on 10 Dec 2009 at 8:19