Fixed a bunch of leaking references in how the callbacks deal with
objects. Should be MUCH better now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		| @@ -1 +1 @@ | ||||
| *.doc | ||||
|  | ||||
|   | ||||
| @@ -488,7 +488,9 @@ static PyObject *_wrap_wxFSFile_GetStream(PyObject *self, PyObject *args, PyObje | ||||
|             Py_DECREF(arg); | ||||
|  | ||||
|             // set ThisOwn | ||||
|             PyObject_SetAttrString(_resultobj, "thisown", PyInt_FromLong(1)); | ||||
|             PyObject* one = PyInt_FromLong(1); | ||||
|             PyObject_SetAttrString(_resultobj, "thisown", one); | ||||
|             Py_DECREF(one); | ||||
|         } | ||||
|     } else { | ||||
|         Py_INCREF(Py_None); | ||||
|   | ||||
| @@ -134,11 +134,11 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
| #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME)                           \ | ||||
|     void CBNAME(wxGridCellAttr *attr, int a, int b) {                   \ | ||||
|         bool doSave = wxPyRestoreThread();                              \ | ||||
|         if (m_myInst.findCallback(#CBNAME))                             \ | ||||
|             m_myInst.callCallback(                                      \ | ||||
|                 Py_BuildValue("(Oii)",                                  \ | ||||
|                               wxPyConstructObject((void*)attr, "wxGridCellAttr"),    \ | ||||
|                               a, b));                                   \ | ||||
|         if (m_myInst.findCallback(#CBNAME)) {                           \ | ||||
|             PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr");\ | ||||
|             m_myInst.callCallback(Py_BuildValue("(Oii)", obj, a, b));   \ | ||||
|             Py_DECREF(obj);                                             \ | ||||
|         }                                                               \ | ||||
|         else                                                            \ | ||||
|             PCLASS::CBNAME(attr, a, b);                                 \ | ||||
|         wxPySaveThread(doSave);                                         \ | ||||
| @@ -152,11 +152,11 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
| #define PYCALLBACK__GCAINT(PCLASS, CBNAME)                              \ | ||||
|     void CBNAME(wxGridCellAttr *attr, int val) {                        \ | ||||
|         bool doSave = wxPyRestoreThread();                              \ | ||||
|         if (m_myInst.findCallback(#CBNAME))                             \ | ||||
|             m_myInst.callCallback(                                      \ | ||||
|                 Py_BuildValue("(Oi)",                                   \ | ||||
|                               wxPyConstructObject((void*)attr, "wxGridCellAttr"),    \ | ||||
|                               val));                                    \ | ||||
|         if (m_myInst.findCallback(#CBNAME)) {                           \ | ||||
|             PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr");\ | ||||
|             m_myInst.callCallback(Py_BuildValue("(Oi)", obj, val));     \ | ||||
|             Py_DECREF(obj);                                             \ | ||||
|         }                                                               \ | ||||
|         else                                                            \ | ||||
|             PCLASS::CBNAME(attr, val);                                  \ | ||||
|         wxPySaveThread(doSave);                                         \ | ||||
| @@ -199,8 +199,9 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
|             PyObject* ro;                                               \ | ||||
|             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \ | ||||
|             if (ro) {                                                   \ | ||||
|                 rval = PyString_AsString(PyObject_Str(ro));             \ | ||||
|                 Py_DECREF(ro);                                          \ | ||||
|                 PyObject* str = PyObject_Str(ro);                       \ | ||||
|                 rval = PyString_AsString(str);                          \ | ||||
|                 Py_DECREF(ro);  Py_DECREF(str);                         \ | ||||
|             }                                                           \ | ||||
|         }                                                               \ | ||||
|         wxPySaveThread(doSave);                                         \ | ||||
| @@ -226,8 +227,9 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
|             PyObject* ro;                                               \ | ||||
|             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \ | ||||
|             if (ro) {                                                   \ | ||||
|                 rval = PyString_AsString(PyObject_Str(ro));             \ | ||||
|                 Py_DECREF(ro);                                          \ | ||||
|                 PyObject* str = PyObject_Str(ro);                       \ | ||||
|                 rval = PyString_AsString(str);                          \ | ||||
|                 Py_DECREF(ro);  Py_DECREF(str);                         \ | ||||
|             }                                                           \ | ||||
|         } else                                                          \ | ||||
|             rval = PCLASS::CBNAME(a, b);                                \ | ||||
| @@ -300,8 +302,9 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
|             PyObject* ro;                                               \ | ||||
|             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",a,b));   \ | ||||
|             if (ro) {                                                   \ | ||||
|                 rval = PyFloat_AsDouble(PyObject_Str(ro));              \ | ||||
|                 Py_DECREF(ro);                                          \ | ||||
|                 PyObject* str = PyObject_Str(ro);                       \ | ||||
|                 rval = PyFloat_AsDouble(str);                           \ | ||||
|                 Py_DECREF(ro);   Py_DECREF(str);                        \ | ||||
|             }                                                           \ | ||||
|         } else                                                          \ | ||||
|             rval = PCLASS::CBNAME(a, b);                                \ | ||||
| @@ -372,8 +375,9 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
|             PyObject* ro;                                               \ | ||||
|             ro = m_myInst.callCallbackObj(Py_BuildValue("(i)",a));      \ | ||||
|             if (ro) {                                                   \ | ||||
|                 rval = PyString_AsString(PyObject_Str(ro));             \ | ||||
|                 Py_DECREF(ro);                                          \ | ||||
|                 PyObject* str = PyObject_Str(ro);                       \ | ||||
|                 rval = PyString_AsString(str);                          \ | ||||
|                 Py_DECREF(ro);   Py_DECREF(str);                        \ | ||||
|             }                                                           \ | ||||
|         } else                                                          \ | ||||
|             rval = PCLASS::CBNAME(a);                                   \ | ||||
| @@ -710,7 +714,6 @@ public: | ||||
|     PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr); | ||||
|  | ||||
|  | ||||
|  | ||||
|     wxString GetValue(int row, int col) { | ||||
|         bool doSave = wxPyRestoreThread(); | ||||
|         wxString rval; | ||||
| @@ -718,8 +721,10 @@ public: | ||||
|             PyObject* ro; | ||||
|             ro = m_myInst.callCallbackObj(Py_BuildValue("(ii)",row,col)); | ||||
|             if (ro) { | ||||
|                 rval = PyString_AsString(PyObject_Str(ro)); | ||||
|                 PyObject* str = PyObject_Str(ro); | ||||
|                 rval = PyString_AsString(str); | ||||
|                 Py_DECREF(ro); | ||||
|                 Py_DECREF(str); | ||||
|             } | ||||
|         } | ||||
|         wxPySaveThread(doSave); | ||||
|   | ||||
| @@ -163,12 +163,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     void OnExit() { | ||||
|         bool doSave = wxPyRestoreThread(); | ||||
|         Py_DECREF(m_tagHandlerClass); | ||||
|         m_tagHandlerClass = NULL; | ||||
|         for (size_t x=0; x < m_objArray.GetCount(); x++) { | ||||
|             PyObject* obj = (PyObject*)m_objArray.Item(x); | ||||
|             Py_DECREF(obj); | ||||
|         } | ||||
|         wxPySaveThread(doSave); | ||||
|     }; | ||||
|  | ||||
|     void FillHandlersTable(wxHtmlWinParser *parser) { | ||||
| @@ -229,6 +231,7 @@ IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); | ||||
|     if (m_myInst.findCallback("OnLinkClicked")) { | ||||
|         PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo"); | ||||
|         m_myInst.callCallback(Py_BuildValue("(O)", obj)); | ||||
|         Py_DECREF(obj); | ||||
|     } | ||||
|     else | ||||
|         wxHtmlWindow::OnLinkClicked(link); | ||||
| @@ -6273,6 +6276,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { | ||||
|     { "_wxBusyInfo","_class_wxBusyInfo",0}, | ||||
|     { "_class_wxMenuEvent","_wxMenuEvent",0}, | ||||
|     { "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0}, | ||||
|     { "_wxJoystick","_class_wxJoystick",0}, | ||||
|     { "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0}, | ||||
|     { "_wxClientDC","_class_wxClientDC",0}, | ||||
|     { "_wxMouseEvent","_class_wxMouseEvent",0}, | ||||
| @@ -6469,6 +6473,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { | ||||
|     { "_wxHtmlParser","_wxHtmlWinParser",SwigwxHtmlWinParserTowxHtmlParser}, | ||||
|     { "_wxHtmlParser","_class_wxHtmlParser",0}, | ||||
|     { "_class_wxBusyInfo","_wxBusyInfo",0}, | ||||
|     { "_class_wxJoystick","_wxJoystick",0}, | ||||
|     { "_class_wxCommandEvent","_wxCommandEvent",0}, | ||||
|     { "_class_wxClientDC","_wxClientDC",0}, | ||||
|     { "_class_wxSizeEvent","_wxSizeEvent",0}, | ||||
|   | ||||
| @@ -3188,6 +3188,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { | ||||
|     { "_wxBusyInfo","_class_wxBusyInfo",0}, | ||||
|     { "_class_wxMenuEvent","_wxMenuEvent",0}, | ||||
|     { "_wxPaletteChangedEvent","_class_wxPaletteChangedEvent",0}, | ||||
|     { "_wxJoystick","_class_wxJoystick",0}, | ||||
|     { "_class_wxPyBitmapDataObject","_wxPyBitmapDataObject",0}, | ||||
|     { "_wxClientDC","_class_wxClientDC",0}, | ||||
|     { "_wxMouseEvent","_class_wxMouseEvent",0}, | ||||
| @@ -3382,6 +3383,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { | ||||
|     { "_class_wxCheckListBox","_wxCheckListBox",0}, | ||||
|     { "_wxHtmlParser","_class_wxHtmlParser",0}, | ||||
|     { "_class_wxBusyInfo","_wxBusyInfo",0}, | ||||
|     { "_class_wxJoystick","_wxJoystick",0}, | ||||
|     { "_class_wxCommandEvent","_wxCommandEvent",0}, | ||||
|     { "_class_wxClientDC","_wxClientDC",0}, | ||||
|     { "_class_wxSizeEvent","_wxSizeEvent",0}, | ||||
|   | ||||
| @@ -121,7 +121,9 @@ static char* wxStringErrorMsg = "string type is required for parameter"; | ||||
|             bool doSave = wxPyRestoreThread(); | ||||
|             wxRect* newRect = new wxRect(dest); | ||||
|             obj = wxPyConstructObject((void*)newRect, "wxRect"); | ||||
|             PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1)); | ||||
|             PyObject* one = PyInt_FromLong(1); | ||||
|             PyObject_SetAttrString(obj, "thisown", one); | ||||
|             Py_DECREF(one); | ||||
|             wxPySaveThread(doSave); | ||||
|             return obj; | ||||
|         } | ||||
|   | ||||
| @@ -400,8 +400,10 @@ public: | ||||
|         if (!PyObject_HasAttrString(py, name)) | ||||
|             return NULL; | ||||
|         PyObject* o = PyObject_GetAttrString(py, name); | ||||
|         if (!PyMethod_Check(o) && !PyCFunction_Check(o)) | ||||
|         if (!PyMethod_Check(o) && !PyCFunction_Check(o)) { | ||||
|             Py_DECREF(o); | ||||
|             return NULL; | ||||
|         } | ||||
|         return o; | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user