Fixing
bug 444128, |MacApplicationDelegate| in toolkit throws ObjC exception when creating a |NSMenuItem| with a |nil| |NSString *|. r=josh, sr=roc
--- a/toolkit/xre/MacApplicationDelegate.mm
+++ b/toolkit/xre/MacApplicationDelegate.mm
@@ -240,19 +240,22 @@ static NSWindow* GetCocoaWindowForXULWin
while (NS_SUCCEEDED(windowList->HasMoreElements(&more)) && more) {
// Get our native window
nsCOMPtr<nsISupports> xulWindow;
rv = windowList->GetNext(getter_AddRefs(xulWindow));
NS_ENSURE_SUCCESS(rv, nil);
NSWindow *cocoaWindow = GetCocoaWindowForXULWindow(xulWindow);
if (!cocoaWindow) continue;
+ NSString *windowTitle = [cocoaWindow title];
+ if (!windowTitle) continue;
+
// Now, create a menu item, and add it to the menu
NSMenuItem *menuItem = [[NSMenuItem alloc]
- initWithTitle:[cocoaWindow title]
+ initWithTitle:windowTitle
action:@selector(dockMenuItemSelected:)
keyEquivalent:@""];
[menuItem setTarget:self];
[menuItem setRepresentedObject:cocoaWindow];
// If this is the foreground window, put a checkmark next to it
if (SameCOMIdentity(xulWindow, frontWindow))
[menuItem setState:NSOnState];