]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
warning fix
[wxWidgets.git] / wxPython / src / helpers.cpp
index ef5fb35e32d9c09e9e1e3dfa56d70bcb9612edfc..512b685baaea8d7455bccd396ffb6e1cbb9b147f 100644 (file)
@@ -866,10 +866,8 @@ bool wxPyCheckForApp() {
 
 //---------------------------------------------------------------------------
 
-
-void wxPyClientData_dtor(wxPyClientData* self) {
-    if (! wxPyDoingCleanup) {           // Don't do it during cleanup as Python
-                                        // may have already garbage collected the object...
+void wxPyUserData_dtor(wxPyUserData* self) {
+    if (! wxPyDoingCleanup) {
         bool blocked = wxPyBeginBlockThreads();
         Py_DECREF(self->m_obj);
         self->m_obj = NULL;
@@ -877,16 +875,21 @@ void wxPyClientData_dtor(wxPyClientData* self) {
     }
 }
 
-void wxPyUserData_dtor(wxPyUserData* self) {
-    if (! wxPyDoingCleanup) {
-        bool blocked = wxPyBeginBlockThreads();
-        Py_DECREF(self->m_obj);
+
+void wxPyClientData_dtor(wxPyClientData* self) {
+    if (! wxPyDoingCleanup) {           // Don't do it during cleanup as Python
+                                        // may have already garbage collected the object...
+        if (self->m_incRef) {
+            bool blocked = wxPyBeginBlockThreads();
+            Py_DECREF(self->m_obj);
+            wxPyEndBlockThreads(blocked);
+        }
         self->m_obj = NULL;
-        wxPyEndBlockThreads(blocked);
     }
 }
 
 
+
 // This is called when an OOR controled object is being destroyed.  Although
 // the C++ object is going away there is no way to force the Python object
 // (and all references to it) to die too.  This causes problems (crashes) in
@@ -909,8 +912,9 @@ void wxPyOORClientData_dtor(wxPyOORClientData* self) {
     }
 
 
-    // Only if there is more than one reference to the object
-    if ( !wxPyDoingCleanup && self->m_obj->ob_refcnt > 1 ) {
+    // Only if there is more than one reference to the object and we are
+    // holding the OOR reference:
+    if ( !wxPyDoingCleanup && self->m_obj->ob_refcnt > 1 && self->m_incRef) {
         // bool isInstance = wxPyInstance_Check(self->m_obj);
         // TODO same here
         //wxASSERT_MSG(isInstance, wxT("m_obj not an instance!?!?!"));
@@ -1473,7 +1477,7 @@ wxFileOffset wxPyCBInputStream::OnSysTell() const {
 
 //----------------------------------------------------------------------
 
-IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxObject);
+IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxEvtHandler);
 
 wxPyCallback::wxPyCallback(PyObject* func) {
     m_func = func;