From ffde60f96bc3f06fc092b48097e84008346f904c Mon Sep 17 00:00:00 2001 From: "smfr%smfr.org" Date: Sat, 27 Aug 2005 03:43:23 +0000 Subject: [PATCH] Fix bug 306084: avoid crashes when closing the last tab (or trying to move it to a new window), and disable the menu items as appropriate. git-svn-id: svn://10.0.0.236/trunk@179123 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/browser/BrowserWindowController.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mozilla/camino/src/browser/BrowserWindowController.mm b/mozilla/camino/src/browser/BrowserWindowController.mm index 271e40ea239..e4c44033583 100644 --- a/mozilla/camino/src/browser/BrowserWindowController.mm +++ b/mozilla/camino/src/browser/BrowserWindowController.mm @@ -1233,6 +1233,22 @@ enum BWCOpenDest { #pragma mark - + +-(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem +{ + SEL action = [aMenuItem action]; + + if (action == @selector(moveTabToNewWindow:) || + action == @selector(closeCurrentTab:) || + action == @selector(closeSendersTab:) || + action == @selector(closeOtherTabs:)) + return ([mTabBrowser numberOfTabViewItems] > 1); + + return YES; +} + +#pragma mark - + // BrowserUIDelegate methods (called from the frontmost tab's BrowserWrapper) @@ -2570,6 +2586,9 @@ enum BWCOpenDest { { [[NSApp delegate] fixCloseMenuItemKeyEquivalents]; [mTabBrowser refreshTabBar:YES]; + // paranoia, to avoid stale mBrowserView pointer (since we don't own it) + if ([aTabView numberOfTabViewItems] == 0) + mBrowserView = nil; } -(BrowserTabView*)getTabBrowser