From 33c6fe9e83ba4d91e66e4c43dde9d8557efa6045 Mon Sep 17 00:00:00 2001 From: wlux Date: Wed, 9 Mar 2011 10:52:43 +0000 Subject: [PATCH] Stop observing notifications from a pop up button's menu when the button is deallocated to prevent obscure crashes later. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32513 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSPopUpButtonCell.m | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index e4472edb3..adbd469af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-09 Wolfgang Lux + + * Source/NSPopUpButtonCell.m (-dealloc): Stop observing + notifications from the button's menu to prevent obscure crashes + later. + 2011-03-09 Wolfgang Lux * Source/NSMatrix.m (_altModifier:): Fix swapped macro arguments, diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index dc7d39b41..85b5821ab 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -147,6 +147,11 @@ static NSImage *_pbc_image[5]; * so the local reference to it is invalid and will result in a * segmentation fault. */ + if (_menu != nil) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc removeObserver: self name: nil object: _menu]; + } _selectedItem = nil; [super dealloc]; }