rsms/chromium-tabs — pull request #15 by elklein (2013-05-01 10:29:40+00:00)
Title: Several fixes to get chromium tabs working under OSX 10.8 or later

I think this probably fixes issues #14, #10 and #9.

* Opening a new window and closing it was crashing. The main root-cause
here was an incorrect autorelease call in the CTBrowser class when
new windows were created. By allowing the autorelease in windowWillClose
to be the one that gets rid of the final reference, the bug primarily went away.

* TabStripController referencing deleted memory after CTBrowser being deallocated.
TabStripController references a C++ class (CTTabStripModel)that is
non-refcounted and owned by CTBrowser. Once the CTBrowser gets deleted,
that class reference becomes stale and cannot be safely used again. Since it
isn't refcounted, the simplest solution is actually just to ensure that
TabStripController gets released before CTBrowser, and then the bug goes away.

* It's possible for CTBrowserWindowController to trigger a window close inside
commandDispatch. This in turn can lead to CTBrowserWindowController getting
destroyed before commandDispatch is finished, with predictably poor results.
Doing a retain and autorelease on the targetController in commandDispatch
fixes this.

* Tearing away a tab and then reintegrating it was causing a crash. The basic
problem was that we were attempting to call makeFirstResponder while in the
process of closing a window. This was because CTTabWindowController calls
setUseOverlay in its dealloc routine, which in turn CAN call NSWindow
makeFirstResponder and display. I've put in an ugly but effective hack to
prevent this. Ideally I'd check some preexisting state on the window or
windowcontroller itself to see if it's valid, but I couldn't find anything
obvious.

Lastly, I also fixed up the XCode project settings to build properly on XCode 4.6
under 10.8. Apple no longer supports building for OSs prior to 10.7, so I updated
the project accordingly.

With this in place I can get the example app working robustly, and should be able
to use this for other purposes as well.