summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_menu_bridge.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 00:37:19 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 00:37:19 +0000
commit668eb917cde85fddb2267325de95aa45f60e1c93 (patch)
treec84d3a5b3d7339fc68d506b6c1dfa873eb0cf4b9 /chrome/browser/cocoa/bookmark_menu_bridge.mm
parent1a8ec651dfb8d68f3a0b2073e80bc9fae7fe8c31 (diff)
downloadchromium_src-668eb917cde85fddb2267325de95aa45f60e1c93.zip
chromium_src-668eb917cde85fddb2267325de95aa45f60e1c93.tar.gz
chromium_src-668eb917cde85fddb2267325de95aa45f60e1c93.tar.bz2
Fix leaks found by valgrind (which now works on the Mac!)
http://code.google.com/p/chromium/issues/detail?id=9376 Review URL: http://codereview.chromium.org/53116 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_menu_bridge.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_menu_bridge.mm10
1 files changed, 8 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.mm b/chrome/browser/cocoa/bookmark_menu_bridge.mm
index 8d32150..f2754a0 100644
--- a/chrome/browser/cocoa/bookmark_menu_bridge.mm
+++ b/chrome/browser/cocoa/bookmark_menu_bridge.mm
@@ -14,12 +14,17 @@
#include "chrome/browser/profile_manager.h"
BookmarkMenuBridge::BookmarkMenuBridge()
- : controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]) {
+ : controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]),
+ observing_(true) {
BrowserList::AddObserver(this);
}
BookmarkMenuBridge::~BookmarkMenuBridge() {
- GetBookmarkModel()->RemoveObserver(this);
+ if (observing_)
+ BrowserList::RemoveObserver(this);
+ BookmarkModel *model = GetBookmarkModel();
+ if (model)
+ model->RemoveObserver(this);
[controller_ release];
}
@@ -98,6 +103,7 @@ void BookmarkMenuBridge::OnBrowserRemoving(const Browser* browser) {
// complete.
void BookmarkMenuBridge::OnBrowserSetLastActive(const Browser* browser) {
BrowserList::RemoveObserver(this);
+ observing_ = false;
BookmarkModel* model = GetBookmarkModel();
model->AddObserver(this);
if (model->IsLoaded())