]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.h
correction for memory leak
[wxWidgets.git] / wxPython / src / helpers.h
index cae2b86d8fee25c22b4baefce3d38255a27a7a00..46d04e9f606cee5dcaf864dd1674b4d1d0083bf6 100644 (file)
@@ -351,6 +351,29 @@ public:
 
 
 
+class wxPyClientData : public wxClientData {
+public:
+    wxPyClientData(PyObject* obj) {
+        m_obj = obj;
+        Py_INCREF(m_obj);
+    }
+
+    ~wxPyClientData() {
+#ifdef wxPyUSE_EXPORT
+        wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads();
+        Py_DECREF(m_obj);
+        wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state);
+#else
+        wxPyTState* state = wxPyBeginBlockThreads();
+        Py_DECREF(m_obj);
+        wxPyEndBlockThreads(state);
+#endif
+    }
+    PyObject* m_obj;
+};
+
+
+
 //---------------------------------------------------------------------------
 // These macros are used to implement the virtual methods that should
 // redirect to a Python method if one exists.  The names designate the