]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/cocoa/ObjcAssociate.h
make wxChoice and wxListBox inherit from wxControlWithItems and not wxControl for...
[wxWidgets.git] / include / wx / cocoa / ObjcAssociate.h
index 4a460143e038789e4aeea932d95b16ce5aaa3829..3ba2f5aa86548bde02d39f8a8359ec564c3830c9 100644 (file)
@@ -2,11 +2,11 @@
 // Name:        wx/cocoa/ObjcAssociate.h
 // Purpose:     Associates an Objective-C class with a C++ class
 // Author:      David Elliott
-// Modified by: 
+// Modified by:
 // Created:     2002/12/03
-// RCS-ID:      $Id:
+// RCS-ID:      $Id$
 // Copyright:   (c) 2002 David Elliott <dfe@cox.net>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef __WX_COCOA_OBJC_ASSOCIATE_H__
@@ -45,18 +45,20 @@ WX_DECLARE_OBJC_INTERFACE_HASHMAP(ObjcClass) \
 public: \
     inline void Associate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
     { \
-        sm_cocoaHash.insert(wxCocoa##ObjcClass##Hash::value_type(cocoaObjcClass,this)); \
+        if(cocoaObjcClass) \
+            sm_cocoaHash.insert(wxCocoa##ObjcClass##Hash::value_type(cocoaObjcClass,this)); \
     } \
     inline void Disassociate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
     { \
-        sm_cocoaHash.erase(cocoaObjcClass); \
+        if(cocoaObjcClass) \
+            sm_cocoaHash.erase(cocoaObjcClass); \
     }
 
 #define WX_IMPLEMENT_OBJC_INTERFACE(ObjcClass) \
 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass)
 
 /*-------------------------------------------------------------------------
-Stuff to be used by the wxWindows class (not the Cocoa interface)
+Stuff to be used by the wxWidgets class (not the Cocoa interface)
 -------------------------------------------------------------------------*/
 #define WX_DECLARE_COCOA_OWNER(ObjcClass,ObjcBase,ObjcRoot) \
 public: \
@@ -68,12 +70,9 @@ protected: \
 #define WX_IMPLEMENT_COCOA_OWNER(wxClass,ObjcClass,ObjcBase,ObjcRoot) \
 void wxClass::Set##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
 { \
-    if(m_cocoa##ObjcRoot) \
-        Disassociate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
+    Disassociate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
     Set##ObjcBase(cocoaObjcClass); \
-    if(m_cocoa##ObjcRoot) \
-        Associate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
+    Associate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
 }
 
 #endif // __WX_COCOA_OBJC_ASSOCIATE_H__
-