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:
Robin Dunn
2000-12-10 08:37:52 +00:00
parent 2d5e89e1cd
commit de20db997d
32 changed files with 408 additions and 184 deletions

View File

@@ -1 +1 @@
ver = '2.3.0b1'
ver = '2.3b1'

View File

@@ -75,7 +75,9 @@
// Py_DECREF(arg);
// // set ThisOwn
// PyObject_SetAttrString($target, "thisown", PyInt_FromLong(1));
// PyObject* one = PyInt_FromLong(1);
// PyObject_SetAttrString($target, "thisown", one);
// Py_DECREF(one);
// }
// } else {
// Py_INCREF(Py_None);

View File

@@ -339,6 +339,7 @@ public:
};
%new wxColour* wxNamedColour(const wxString& colorName);
%{ // Alternate 'constructor'
wxColour* wxNamedColour(const wxString& colorName) {
return new wxColour(colorName);

View File

@@ -71,11 +71,11 @@
#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); \
@@ -89,11 +89,11 @@
#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); \
@@ -136,8 +136,9 @@
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); \
@@ -163,8 +164,9 @@
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); \
@@ -237,8 +239,9 @@
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); \
@@ -309,8 +312,9 @@
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); \
@@ -982,7 +986,6 @@ public:
PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
wxString GetValue(int row, int col) {
bool doSave = wxPyRestoreThread();
wxString rval;
@@ -990,8 +993,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);

View File

@@ -105,6 +105,11 @@ int wxPyApp::MainLoop(void) {
//---------------------------------------------------------------------
//----------------------------------------------------------------------
#ifdef __WXMSW__
#include "wx/msw/msvcrt.h"
#endif
int WXDLLEXPORT wxEntryStart( int argc, char** argv );
int WXDLLEXPORT wxEntryInitGui();
void WXDLLEXPORT wxEntryCleanup();
@@ -121,6 +126,11 @@ static char* __nullArgv[1] = { 0 };
// wxcmodule is imported. (Before there is a wxApp object.)
void __wxPreStart()
{
#ifdef __WXMSW__
// wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef WXP_WITH_THREAD
PyEval_InitThreads();
wxPyEventThreadState = PyThreadState_Get();
@@ -158,11 +168,12 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
if (!PyArg_ParseTuple(args, "O", &onInitFunc))
return NULL;
#if 0 // Try it out without this check, soo how it does...
if (wxTopLevelWindows.Number() > 0) {
PyErr_SetString(PyExc_TypeError, "Only 1 wxApp per process!");
return NULL;
}
#endif
// This is the next part of the wxEntry functionality...
PyObject* sysargv = PySys_GetObject("argv");
@@ -280,7 +291,9 @@ PyObject* wxPyConstructObject(void* ptr,
Py_DECREF(arg);
if (setThisOwn) {
PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString(obj, "thisown", one);
Py_DECREF(one);
}
return obj;
@@ -427,12 +440,12 @@ void wxPyCallbackHelper::setSelf(PyObject* self, PyObject* klass, int incref) {
// If the object (m_self) has an attibute of the given name, and if that
// attribute is a method, and if that method's class is not from a base class,
// then we'll save a pointer to the method so callCallback can call it.
bool wxPyCallbackHelper::findCallback(const wxString& name) const {
bool wxPyCallbackHelper::findCallback(const char* name) const {
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
self->m_lastFound = NULL;
if (m_self && PyObject_HasAttrString(m_self, (char*)name.c_str())) {
if (m_self && PyObject_HasAttrString(m_self, (char*)name)) {
PyObject* method;
method = PyObject_GetAttrString(m_self, (char*)name.c_str());
method = PyObject_GetAttrString(m_self, (char*)name);
if (PyMethod_Check(method) &&
((PyMethod_GET_CLASS(method) == m_class) ||
@@ -440,6 +453,9 @@ bool wxPyCallbackHelper::findCallback(const wxString& name) const {
self->m_lastFound = method;
}
else {
Py_DECREF(method);
}
}
return m_lastFound != NULL;
}
@@ -461,10 +477,17 @@ int wxPyCallbackHelper::callCallback(PyObject* argTuple) const {
// Invoke the Python callable object, returning the raw PyObject return
// value. Caller should DECREF the return value and also call PyEval_SaveThread.
PyObject* wxPyCallbackHelper::callCallbackObj(PyObject* argTuple) const {
PyObject* result;
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
PyObject* result;
result = PyEval_CallObject(m_lastFound, argTuple);
// Save a copy of the pointer in case the callback generates another
// callback. In that case m_lastFound will have a different value when
// it gets back here...
PyObject* method = m_lastFound;
result = PyEval_CallObject(method, argTuple);
Py_DECREF(argTuple);
Py_DECREF(method);
if (!result) {
PyErr_Print();
}
@@ -987,7 +1010,7 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
}
error:
PyErr_SetString(PyExc_TypeError, "Expected a wxColour object or a string containing a colour name or #RRGGBB.");
PyErr_SetString(PyExc_TypeError, "Expected a wxColour object or a string containing a colour name or '#RRGGBB'.");
return FALSE;
}
@@ -998,3 +1021,4 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {

View File

@@ -15,7 +15,6 @@
#include <wx/wx.h>
//----------------------------------------------------------------------
// if we want to handle threads and Python threads are available...
@@ -216,7 +215,7 @@ public:
void setSelf(PyObject* self, PyObject* klass, int incref=TRUE);
bool findCallback(const wxString& name) const;
bool findCallback(const char* name) const;
int callCallback(PyObject* argTuple) const;
PyObject* callCallbackObj(PyObject* argTuple) const;
@@ -393,9 +392,11 @@ public:
#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, "wxDC"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
@@ -416,9 +417,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), (int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@@ -437,9 +440,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), (int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@@ -499,10 +504,11 @@ public:
#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e, (int)f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@@ -522,10 +528,11 @@ public:
bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
bool doSave = wxPyRestoreThread(); \
bool rval; \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e, (int)f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
Py_DECREF(obj); \
} \
else \
rval = PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@@ -566,10 +573,11 @@ public:
#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Odddd)", \
wxPyConstructObject(&a, "wxDC"), \
b, c, d, e)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e); \
wxPySaveThread(doSave); \
@@ -588,10 +596,11 @@ public:
#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxDC& a, bool b) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oi)", \
wxPyConstructObject(&a, "wxDC"), \
(int)b)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(&a, "wxDC"); \
m_myInst.callCallback(Py_BuildValue("(Oi)", obj, (int)b)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b); \
wxPySaveThread(doSave); \
@@ -611,10 +620,11 @@ public:
void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
int e, int f) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
wxPyConstructObject(a, "wxPyControlPoint"), \
(int)b, c, d, e, f)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint"); \
m_myInst.callCallback(Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e, f); \
wxPySaveThread(doSave); \
@@ -634,10 +644,11 @@ public:
#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(Oddii)", \
wxPyConstructObject(a, "wxPyControlPoint"), \
b, c, d, e)); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint"); \
m_myInst.callCallback(Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a, b, c, d, e); \
wxPySaveThread(doSave); \
@@ -758,8 +769,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("(s)", a.c_str())); \
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); \
@@ -779,8 +791,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("(si)", a.c_str(),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); \
@@ -825,8 +838,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
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 \
@@ -852,8 +866,9 @@ public:
PyObject* ro; \
ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
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); \
@@ -870,9 +885,11 @@ public:
bool CLASS::CBNAME(const wxHtmlTag& a) { \
bool rval = FALSE; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a,"wxHtmlTag"); \
rval = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
wxPySaveThread(doSave); \
return rval; \
}
@@ -926,9 +943,11 @@ public:
bool CLASS::CBNAME(wxWindow* a) { \
bool rval; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rval = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)a,"wxWindow"))); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)a,"wxWindow"); \
rval = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
rval = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
@@ -993,13 +1012,15 @@ public:
wxFSFile* rval=0; \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* ro; \
ro=m_myInst.callCallbackObj(Py_BuildValue("(Os)", \
wxPyConstructObject(&a, "(wxFileSystemC"),b.c_str())); \
PyObject* obj = wxPyConstructObject(&a, "(wxFileSystem"); \
ro = m_myInst.callCallbackObj(Py_BuildValue("(Os)", \
obj, b.c_str())); \
if (ro) { \
SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
Py_DECREF(ro); \
} \
} \
Py_DECREF(obj); \
} \
wxPySaveThread(doSave); \
return rval; \
};
@@ -1117,18 +1138,20 @@ public:
void base_##CBNAME(const Type& a);
#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(const Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject((void*)&a, #Type))); \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(const Type& a) { \
PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(const Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(const Type& a) { \
PCLASS::CBNAME(a); \
}
@@ -1139,18 +1162,20 @@ public:
void base_##CBNAME(Type& a);
#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, #Type))); \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(Type& a) { \
PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(Type& a) { \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
} \
void CLASS::base_##CBNAME(Type& a) { \
PCLASS::CBNAME(a); \
}
//---------------------------------------------------------------------------
@@ -1160,20 +1185,22 @@ public:
bool base_##CBNAME(Type& a);
#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
bool CLASS::CBNAME(Type& a) { \
bool rv; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) \
rv = m_myInst.callCallback(Py_BuildValue("(O)", \
wxPyConstructObject(&a, #Type))); \
else \
rv = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
return rv; \
} \
bool CLASS::base_##CBNAME(Type& a) { \
return PCLASS::CBNAME(a); \
#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
bool CLASS::CBNAME(Type& a) { \
bool rv; \
bool doSave = wxPyRestoreThread(); \
if (m_myInst.findCallback(#CBNAME)) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type); \
rv = m_myInst.callCallback(Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
else \
rv = PCLASS::CBNAME(a); \
wxPySaveThread(doSave); \
return rv; \
} \
bool CLASS::base_##CBNAME(Type& a) { \
return PCLASS::CBNAME(a); \
}
//---------------------------------------------------------------------------

View File

@@ -275,12 +275,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) {
@@ -434,6 +436,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);

View File

@@ -255,7 +255,9 @@ public:
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;
}

View File

@@ -1 +1 @@
*.doc

View File

@@ -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);

View File

@@ -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);

View File

@@ -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},

View File

@@ -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},

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -264,7 +264,7 @@ static char* wxStringErrorMsg = "string type is required for parameter";
//---------------------------------------------------------------------------
// Typemap to convert strings to wxColour. Two string formats are accepted,
// either a colour name, for a hex colour spec like "#RRGGBB"
// either a colour name, or a hex colour spec like "#RRGGBB"
%typemap(python,in) wxColour& (wxColour temp) {
$target = &temp;

View File

@@ -67,7 +67,9 @@
Py_DECREF(arg);
// set ThisOwn
PyObject_SetAttrString($target, "thisown", PyInt_FromLong(1));
PyObject* one = PyInt_FromLong(1);
PyObject_SetAttrString($target, "thisown", one);
Py_DECREF(one);
}
} else {
Py_INCREF(Py_None);
@@ -371,8 +373,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;
}

View File

@@ -52,7 +52,7 @@
//---------------------------------------------------------------------------
#define __version__ "0.0.0" // The real value is now in build.py...
#define __version__ "0.0.0" // The real value is now in setup.py...
wxPoint wxPyDefaultPosition;
wxSize wxPyDefaultSize;