]> git.saurik.com Git - wxWidgets.git/commitdiff
It was not acceptable to call the class method from the static initializer
authorDavid Elliott <dfe@tgwbd.org>
Wed, 2 Jul 2003 20:46:34 +0000 (20:46 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Wed, 2 Jul 2003 20:46:34 +0000 (20:46 +0000)
because it caused the load and initialize methods to be called.  Some of the
load and initialize methods used autorelease which would lead to warnings
about memory leaks (true, though very benign).
This version delays all Objective-C calls until InitializePosers().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21585 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/ObjcPose.h

index b5e53c0ab6c32dbc54e78f0504609bd6949e60b8..3697cecf7d0e9099e515fa84b3c4b08536cb8aed 100644 (file)
@@ -17,19 +17,18 @@ Objective-C Poser class initialization
 -------------------------------------------------------------------------*/
 #ifdef __OBJC__
 #import <objc/objc-class.h>
+#import <Foundation/NSObjcRuntime.h>
 
 class wxPoseAsInitializer
 {
 public:
-       wxPoseAsInitializer(Class poser)
-       : m_poser(poser)
-       , m_next(sm_first)
+       wxPoseAsInitializer()
+       : m_next(sm_first)
        {
                sm_first = this;
        }
-       ~wxPoseAsInitializer()
+       virtual ~wxPoseAsInitializer()
        {
-               class_poseAs(m_poser,m_poser->super_class);
                sm_first = m_next;
        }
        static void InitializePosers()
@@ -40,7 +39,6 @@ public:
                }
        };
 protected:
-       Class m_poser;
        wxPoseAsInitializer *m_next;
        static wxPoseAsInitializer *sm_first;
 };
@@ -52,7 +50,15 @@ public:
 };
 
 #define WX_IMPLEMENT_POSER(poser) \
-wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializer([poser class]))
+class wxPoseAsInitializerFor##poser: public wxPoseAsInitializer \
+{ \
+protected: \
+    virtual ~wxPoseAsInitializerFor##poser() \
+    { \
+        class_poseAs([poser class],[poser superclass]); \
+    } \
+}; \
+wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializerFor##poser)
 
 #else // __OBJC__
 #warning "Objective-C++ Only!"