]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/NSView.mm
Initial move from C to C++. The functionality of the code should not have
[wxWidgets.git] / src / cocoa / NSView.mm
index 280c06b91b3c5d6824f00c56e67e940ca802732c..7f880656e6918117bc20fd5b79e36e4017a2bd73 100644 (file)
@@ -36,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];
+    }
 }
 
 // ============================================================================