X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe802fc2edc8e3e78f812254582af0ee91da2ea0..d1fc6f065885a749930c86fdb0200f3220ad86b5:/src/cocoa/NSView.mm?ds=sidebyside diff --git a/src/cocoa/NSView.mm b/src/cocoa/NSView.mm index ec0be69062..7f880656e6 100644 --- a/src/cocoa/NSView.mm +++ b/src/cocoa/NSView.mm @@ -22,6 +22,7 @@ #include "wx/window.h" #endif // WX_PRECOMP +#include "wx/cocoa/ObjcPose.h" #include "wx/cocoa/NSView.h" #import @@ -35,15 +36,21 @@ WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSView) void wxCocoaNSView::AssociateNSView(WX_NSView cocoaNSView) { - sm_cocoaHash.insert(wxCocoaNSViewHash::value_type(cocoaNSView,this)); - [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(notificationFrameChanged:) name:@"NSViewFrameDidChangeNotification" object:cocoaNSView]; - [cocoaNSView setPostsFrameChangedNotifications: YES]; + if(cocoaNSView) + { + sm_cocoaHash.insert(wxCocoaNSViewHash::value_type(cocoaNSView,this)); + [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(notificationFrameChanged:) name:@"NSViewFrameDidChangeNotification" object:cocoaNSView]; + [cocoaNSView setPostsFrameChangedNotifications: YES]; + } } void wxCocoaNSView::DisassociateNSView(WX_NSView cocoaNSView) { - sm_cocoaHash.erase(cocoaNSView); - [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:@"NSViewFrameDidChangeNotification" object:cocoaNSView]; + if(cocoaNSView) + { + sm_cocoaHash.erase(cocoaNSView); + [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:@"NSViewFrameDidChangeNotification" object:cocoaNSView]; + } } // ============================================================================