From 19a97bd6f98edc899ee0c3b2f2c4fe4ee8a0082b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sun, 16 Sep 2001 01:51:13 +0000 Subject: [PATCH] Significantly changed how the Python interpreter lock and thread state are managed, which should fix the problem of running on a multi-processor machine. Some fixes for some of the contributed library modules. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/CHANGES.txt | 4 + wxPython/contrib/ogl/ogl.cpp | 22 +- wxPython/contrib/ogl/ogl.i | 20 +- wxPython/contrib/ogl/oglbasic.cpp | 2 + wxPython/contrib/ogl/oglcanvas.cpp | 2 + wxPython/contrib/ogl/oglshapes.cpp | 2 + wxPython/contrib/ogl/oglshapes2.cpp | 2 + wxPython/demo/GridSimple.py | 32 +- wxPython/demo/TablePrint.py | 1 - wxPython/demo/wxProcess.py | 3 +- wxPython/setup.py | 2 +- wxPython/src/__version__.py | 2 +- wxPython/src/clip_dnd.i | 20 +- wxPython/src/controls2.i | 29 +- wxPython/src/export.h | 5 +- wxPython/src/gdi.i | 1 + wxPython/src/grid.i | 663 ++++++++-------- wxPython/src/helpers.cpp | 115 ++- wxPython/src/helpers.h | 690 +++++++++-------- wxPython/src/html.i | 17 +- wxPython/src/misc.i | 4 +- wxPython/src/misc2.i | 1 + wxPython/src/msw/clip_dnd.cpp | 20 +- wxPython/src/msw/controls2.cpp | 29 +- wxPython/src/msw/gdi.cpp | 38 + wxPython/src/msw/gdi.py | 3 + wxPython/src/msw/grid.cpp | 1013 ++++++++++++++++--------- wxPython/src/msw/grid.py | 70 ++ wxPython/src/msw/html.cpp | 17 +- wxPython/src/msw/misc.cpp | 4 +- wxPython/src/msw/misc2.cpp | 1 + wxPython/src/msw/printfw.cpp | 10 +- wxPython/src/msw/streams.cpp | 16 +- wxPython/src/msw/windows.cpp | 8 +- wxPython/src/msw/wx.cpp | 5 +- wxPython/src/printfw.i | 10 +- wxPython/src/streams.i | 16 +- wxPython/src/windows.i | 8 +- wxPython/src/wx.i | 5 +- wxPython/wxPython/lib/colourselect.py | 23 +- wxPython/wxPython/lib/printout.py | 9 +- 41 files changed, 1752 insertions(+), 1192 deletions(-) diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index 3169d4befb..11130bdba4 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -42,6 +42,10 @@ Added wxNativeFontInfo and wxFontMapper. Added pySketch to the samples. +Significantly changed how the Python interpreter lock and thread state +are managed, which should fix the problem of running on a +multi-processor machine. + 2.3.1 diff --git a/wxPython/contrib/ogl/ogl.cpp b/wxPython/contrib/ogl/ogl.cpp index 4e550c6ef4..604a13e63e 100644 --- a/wxPython/contrib/ogl/ogl.cpp +++ b/wxPython/contrib/ogl/ogl.cpp @@ -96,17 +96,17 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { // the helper needs to know more about the type. wxList* wxPy_wxListHelper(PyObject* pyList, char* className) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } for (int x=0; xAppend(wxo); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return list; } //--------------------------------------------------------------------------- wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } for (int x=0; xAppend((wxObject*) new wxRealPoint(*wxo)); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return list; } @@ -271,12 +271,14 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_uint","_wxWindowID",0}, { "_wxChar","_char",0}, { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, { "_EBool","_wxCoord",0}, { "_EBool","_wxPrintQuality",0}, { "_EBool","_signed_int",0}, { "_EBool","_int",0}, { "_EBool","_wxWindowID",0}, { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, { "_signed_int","_wxCoord",0}, { "_signed_int","_wxPrintQuality",0}, { "_signed_int","_EBool",0}, diff --git a/wxPython/contrib/ogl/ogl.i b/wxPython/contrib/ogl/ogl.i index cf221345be..41f78d72fc 100644 --- a/wxPython/contrib/ogl/ogl.i +++ b/wxPython/contrib/ogl/ogl.i @@ -139,17 +139,17 @@ void wxOGLCleanUp(); // the helper needs to know more about the type. wxList* wxPy_wxListHelper(PyObject* pyList, char* className) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } for (int x=0; xAppend(wxo); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return list; } //--------------------------------------------------------------------------- wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return NULL; } for (int x=0; xAppend((wxObject*) new wxRealPoint(*wxo)); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return list; } diff --git a/wxPython/contrib/ogl/oglbasic.cpp b/wxPython/contrib/ogl/oglbasic.cpp index a96160c122..26037831b1 100644 --- a/wxPython/contrib/ogl/oglbasic.cpp +++ b/wxPython/contrib/ogl/oglbasic.cpp @@ -8379,12 +8379,14 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_uint","_wxWindowID",0}, { "_wxChar","_char",0}, { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, { "_EBool","_wxCoord",0}, { "_EBool","_wxPrintQuality",0}, { "_EBool","_signed_int",0}, { "_EBool","_int",0}, { "_EBool","_wxWindowID",0}, { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, { "_signed_int","_wxCoord",0}, { "_signed_int","_wxPrintQuality",0}, { "_signed_int","_EBool",0}, diff --git a/wxPython/contrib/ogl/oglcanvas.cpp b/wxPython/contrib/ogl/oglcanvas.cpp index a8de1a7ce4..e91913d346 100644 --- a/wxPython/contrib/ogl/oglcanvas.cpp +++ b/wxPython/contrib/ogl/oglcanvas.cpp @@ -1977,12 +1977,14 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_uint","_wxWindowID",0}, { "_wxChar","_char",0}, { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, { "_EBool","_wxCoord",0}, { "_EBool","_wxPrintQuality",0}, { "_EBool","_signed_int",0}, { "_EBool","_int",0}, { "_EBool","_wxWindowID",0}, { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, { "_signed_int","_wxCoord",0}, { "_signed_int","_wxPrintQuality",0}, { "_signed_int","_EBool",0}, diff --git a/wxPython/contrib/ogl/oglshapes.cpp b/wxPython/contrib/ogl/oglshapes.cpp index 0e332f9631..ba964f5df2 100644 --- a/wxPython/contrib/ogl/oglshapes.cpp +++ b/wxPython/contrib/ogl/oglshapes.cpp @@ -12604,12 +12604,14 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_uint","_wxWindowID",0}, { "_wxChar","_char",0}, { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, { "_EBool","_wxCoord",0}, { "_EBool","_wxPrintQuality",0}, { "_EBool","_signed_int",0}, { "_EBool","_int",0}, { "_EBool","_wxWindowID",0}, { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, { "_signed_int","_wxCoord",0}, { "_signed_int","_wxPrintQuality",0}, { "_signed_int","_EBool",0}, diff --git a/wxPython/contrib/ogl/oglshapes2.cpp b/wxPython/contrib/ogl/oglshapes2.cpp index 228746c1b1..1695056250 100644 --- a/wxPython/contrib/ogl/oglshapes2.cpp +++ b/wxPython/contrib/ogl/oglshapes2.cpp @@ -7949,12 +7949,14 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_uint","_wxWindowID",0}, { "_wxChar","_char",0}, { "_char","_wxChar",0}, + { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, { "_EBool","_wxCoord",0}, { "_EBool","_wxPrintQuality",0}, { "_EBool","_signed_int",0}, { "_EBool","_int",0}, { "_EBool","_wxWindowID",0}, { "_unsigned_long","_long",0}, + { "_wxNativeFontInfo","_struct_wxNativeFontInfo",0}, { "_signed_int","_wxCoord",0}, { "_signed_int","_wxPrintQuality",0}, { "_signed_int","_EBool",0}, diff --git a/wxPython/demo/GridSimple.py b/wxPython/demo/GridSimple.py index e3a1d16d93..c073d48932 100644 --- a/wxPython/demo/GridSimple.py +++ b/wxPython/demo/GridSimple.py @@ -71,6 +71,7 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin): EVT_GRID_EDITOR_CREATED(self, self.OnEditorCreated) + def OnCellLeftClick(self, evt): self.log.write("OnCellLeftClick: (%d,%d) %s\n" % (evt.GetRow(), evt.GetCol(), evt.GetPosition())) @@ -186,37 +187,8 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin): class TestFrame(wxFrame): def __init__(self, parent, log): wxFrame.__init__(self, parent, -1, "Simple Grid Demo", size=(640,480)) - self.grid = grid = SimpleGrid(self, log) - - self.mainmenu = wxMenuBar() - - menu = wxMenu() - - mID = NewId() - menu.Append(mID, 'Preview Grid', 'Print Displayed Grid') - EVT_MENU(self, mID, self.OnPreviewGrid) - self.mainmenu.Append(menu, '&Print') - - self.SetMenuBar(self.mainmenu) - - def OnPreviewGrid(self, event): - from wxPython.lib.printout import PrintGrid - grid = self.grid - - total_col = 4 # not all columns to be used for printing - total_row = 4 - - format = [1, 1.5, 2.5, 4, 5, 7] # column spacing - - # class to print and preview - prt = PrintGrid(self, grid, format, total_col, total_row ) - prt.SetAttributes() # get the colour and text attributes - - table = prt.GetTable() # the table print control class - table.SetHeader("Simple Grid Test Header") - table.SetFooter() + grid = SimpleGrid(self, log) - prt.Preview() # preview the table #--------------------------------------------------------------------------- diff --git a/wxPython/demo/TablePrint.py b/wxPython/demo/TablePrint.py index f1fa250130..c2c5255b5d 100644 --- a/wxPython/demo/TablePrint.py +++ b/wxPython/demo/TablePrint.py @@ -41,7 +41,6 @@ class TablePanel(wxPanel): def ReadData(self): test_file = "TestTable.txt" - print "**** ", os.getcwd() file = open(test_file,'r',1) i = 0 diff --git a/wxPython/demo/wxProcess.py b/wxPython/demo/wxProcess.py index 4e25bd6e6d..1138651bc6 100644 --- a/wxPython/demo/wxProcess.py +++ b/wxPython/demo/wxProcess.py @@ -91,8 +91,9 @@ class TestPanel(wxPanel): def OnCloseStream(self, evt): self.log.write('OnCloseStream\n') + print "b4 CloseOutput" self.process.CloseOutput() - + print "after CloseOutput" def OnIdle(self, evt): if self.process is not None: diff --git a/wxPython/setup.py b/wxPython/setup.py index d9a0bb2e23..b1788a4661 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -13,7 +13,7 @@ from my_distutils import run_swig, contrib_copy_tree # flags and values that affect this script #---------------------------------------------------------------------- -VERSION = "2.3.2b2" +VERSION = "2.3.2b3" DESCRIPTION = "Cross platform GUI toolkit for Python" AUTHOR = "Robin Dunn" AUTHOR_EMAIL = "Robin Dunn " diff --git a/wxPython/src/__version__.py b/wxPython/src/__version__.py index f50900a001..c0c68381eb 100644 --- a/wxPython/src/__version__.py +++ b/wxPython/src/__version__.py @@ -1 +1 @@ -ver = '2.3.2b2' +ver = '2.3.2b3' diff --git a/wxPython/src/clip_dnd.i b/wxPython/src/clip_dnd.i index 0fb2200a31..634a2f06fc 100644 --- a/wxPython/src/clip_dnd.i +++ b/wxPython/src/clip_dnd.i @@ -147,7 +147,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { // C++ version. bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetDataHere")) { PyObject* ro; ro = m_myInst.callCallbackObj(Py_BuildValue("()")); @@ -158,7 +158,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -166,13 +166,13 @@ bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) { // For this one we simply need to make a string from buf and len // and send it to the Python method. bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("SetData")) { PyObject* data = PyString_FromStringAndSize((char*)buf, len); rval = m_myInst.callCallback(Py_BuildValue("(O)", data)); Py_DECREF(data); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } %} @@ -264,7 +264,7 @@ public: wxBitmap wxPyBitmapDataObject::GetBitmap() { wxBitmap* rval = &wxNullBitmap; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetBitmap")) { PyObject* ro; wxBitmap* ptr; @@ -275,17 +275,17 @@ wxBitmap wxPyBitmapDataObject::GetBitmap() { Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return *rval; } void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("SetBitmap")) { m_myInst.callCallback(Py_BuildValue("(O)", wxPyConstructObject((void*)&bitmap, "wxBitmap"))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } %} @@ -583,7 +583,7 @@ public: bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) { bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* list = PyList_New(0); for (size_t i=0; iGetBoundingRect(item, rect, textOnly)) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxRect* r = new wxRect(rect); PyObject* val = wxPyConstructObject((void*)r, "wxRect"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return val; } else { diff --git a/wxPython/src/export.h b/wxPython/src/export.h index 29f38b7026..5e3301a0b3 100644 --- a/wxPython/src/export.h +++ b/wxPython/src/export.h @@ -33,8 +33,9 @@ static void wxPyCoreAPI_IMPORT() { #define SWIG_RegisterMapping(a, b, c) (wxPyCoreAPIPtr->p_SWIG_RegisterMapping(a, b, c)) #define SWIG_addvarlink(a, b, c, d) (wxPyCoreAPIPtr->p_SWIG_addvarlink(a, b, c, d)) -#define wxPyRestoreThread() (wxPyCoreAPIPtr->p_wxPyRestoreThread()) -#define wxPySaveThread(a) (wxPyCoreAPIPtr->p_wxPySaveThread(a)) +#define wxPyBeginBlockThreads() (wxPyCoreAPIPtr->p_wxPyBeginBlockThreads()) +#define wxPyEndBlockThreads(a) (wxPyCoreAPIPtr->p_wxPyEndBlockThreads(a)) + #define wxPyConstructObject(a,b,c) (wxPyCoreAPIPtr->p_wxPyConstructObject(a,b,c)) #define wxPy_ConvertList(a,b) (wxPyCoreAPIPtr->p_wxPy_ConvertList(a,b)) #define byte_LIST_helper(a) (wxPyCoreAPIPtr->p_byte_LIST_helper(a)) diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 3feb977640..8474a1fa01 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -750,6 +750,7 @@ public: void SetBackground(const wxBrush& brush); void SetBackgroundMode(int mode); void SetClippingRegion(long x, long y, long width, long height); + %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); void SetPalette(const wxPalette& colourMap); void SetBrush(const wxBrush& brush); void SetFont(const wxFont& font); diff --git a/wxPython/src/grid.i b/wxPython/src/grid.i index b9e0a9c81d..f8332e5e23 100644 --- a/wxPython/src/grid.i +++ b/wxPython/src/grid.i @@ -17,6 +17,7 @@ %{ #include "export.h" #include +#include %} //---------------------------------------------------------------------- @@ -46,8 +47,9 @@ #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME) \ wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ wxGridCellAttr* rval = NULL; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ wxGridCellAttr* ptr; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \ @@ -57,9 +59,9 @@ Py_DECREF(ro); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a, b, c); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ @@ -68,356 +70,376 @@ -#define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \ - void CBNAME(wxGridCellAttr *attr, int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ +#define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \ + void CBNAME(wxGridCellAttr *attr, int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool found; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(attr, a, b); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \ - PCLASS::CBNAME(attr, a, b); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(attr, a, b); \ + } \ + void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \ + PCLASS::CBNAME(attr, a, b); \ } -#define PYCALLBACK__GCAINT(PCLASS, CBNAME) \ - void CBNAME(wxGridCellAttr *attr, int val) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ +#define PYCALLBACK__GCAINT(PCLASS, CBNAME) \ + void CBNAME(wxGridCellAttr *attr, int val) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool found; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(attr, val); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(wxGridCellAttr *attr, int val) { \ - PCLASS::CBNAME(attr, val); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(attr, val); \ + } \ + void base_##CBNAME(wxGridCellAttr *attr, int val) { \ + PCLASS::CBNAME(attr, val); \ } -#define PYCALLBACK_INT__pure(CBNAME) \ - int CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - int rval = 0; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - wxPySaveThread(doSave); \ - return rval; \ +#define PYCALLBACK_INT__pure(CBNAME) \ + int CBNAME() { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + int rval = 0; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + return rval; \ } -#define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \ - bool CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - bool rval = 0; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ - wxPySaveThread(doSave); \ - return rval; \ +#define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \ + bool CBNAME(int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool rval = 0; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ + wxPyEndBlockThreads(state); \ + return rval; \ } -#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \ - wxString CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } \ - wxPySaveThread(doSave); \ - return rval; \ +#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \ + wxString CBNAME(int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + return rval; \ } -#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \ - void CBNAME(int a, int b, const wxString& c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str())); \ - wxPySaveThread(doSave); \ +#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \ + void CBNAME(int a, int b, const wxString& c) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ + wxPyEndBlockThreads(state); \ } -#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \ - wxString CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - wxString base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a, b); \ +#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \ + wxString CBNAME(int a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b); \ + return rval; \ + } \ + wxString base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a, b); \ } -#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \ - bool CBNAME(int a, int b, const wxString& c) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str())); \ - else \ - rval = PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(int a, int b, const wxString& c) { \ - return PCLASS::CBNAME(a,b,c); \ +#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \ + bool CBNAME(int a, int b, const wxString& c) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));\ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b,c); \ + return rval; \ + } \ + bool base_##CBNAME(int a, int b, const wxString& c) { \ + return PCLASS::CBNAME(a,b,c); \ } -#define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \ - long CBNAME(int a, int b) { \ - long rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - long base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a,b); \ +#define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \ + long CBNAME(int a, int b) { \ + long rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + long base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a,b); \ } -#define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \ - bool CBNAME(int a, int b) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a,b); \ +#define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \ + bool CBNAME(int a, int b) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + bool base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a,b); \ } -#define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \ - double CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - double rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyFloat_AsDouble(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - double base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a, b); \ +#define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \ + double CBNAME(int a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + double rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyFloat_AsDouble(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b); \ + return rval; \ + } \ + double base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a, b); \ } -#define PYCALLBACK__(PCLASS, CBNAME) \ - void CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME() { \ - PCLASS::CBNAME(); \ +#define PYCALLBACK__(PCLASS, CBNAME) \ + void CBNAME() { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(); \ + } \ + void base_##CBNAME() { \ + PCLASS::CBNAME(); \ } -#define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \ - bool CBNAME(size_t a, size_t b) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(size_t a, size_t b) { \ - return PCLASS::CBNAME(a,b); \ +#define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \ + bool CBNAME(size_t a, size_t b) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + bool base_##CBNAME(size_t a, size_t b) { \ + return PCLASS::CBNAME(a,b); \ } -#define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \ - bool CBNAME(size_t a) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ - else \ - rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(size_t a) { \ - return PCLASS::CBNAME(a); \ +#define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \ + bool CBNAME(size_t a) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + bool base_##CBNAME(size_t a) { \ + return PCLASS::CBNAME(a); \ } -#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \ - wxString CBNAME(int a) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - wxString base_##CBNAME(int a) { \ - return PCLASS::CBNAME(a); \ +#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \ + wxString CBNAME(int a) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + wxString base_##CBNAME(int a) { \ + return PCLASS::CBNAME(a); \ } -#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \ - void CBNAME(int a, const wxString& c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \ - else \ - PCLASS::CBNAME(a,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, const wxString& c) { \ - PCLASS::CBNAME(a,c); \ +#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \ + void CBNAME(int a, const wxString& c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,c); \ + } \ + void base_##CBNAME(int a, const wxString& c) { \ + PCLASS::CBNAME(a,c); \ } -#define PYCALLBACK_BOOL_(PCLASS, CBNAME) \ - bool CBNAME() { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - rval = PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME() { \ - return PCLASS::CBNAME(); \ +#define PYCALLBACK_BOOL_(PCLASS, CBNAME) \ + bool CBNAME() { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(); \ + return rval; \ + } \ + bool base_##CBNAME() { \ + return PCLASS::CBNAME(); \ } -#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \ - void CBNAME(size_t a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(size_t a, int b) { \ - PCLASS::CBNAME(a,b); \ +#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \ + void CBNAME(size_t a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b); \ + } \ + void base_##CBNAME(size_t a, int b) { \ + PCLASS::CBNAME(a,b); \ } -#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \ - void CBNAME(int a, int b, long c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, long c) { \ - PCLASS::CBNAME(a,b,c); \ +#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \ + void CBNAME(int a, int b, long c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, long c) { \ + PCLASS::CBNAME(a,b,c); \ } -#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \ - void CBNAME(int a, int b, double c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, double c) { \ - PCLASS::CBNAME(a,b,c); \ +#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \ + void CBNAME(int a, int b, double c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, double c) { \ + PCLASS::CBNAME(a,b,c); \ } -#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \ - void CBNAME(int a, int b, bool c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, bool c) { \ - PCLASS::CBNAME(a,b,c); \ +#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \ + void CBNAME(int a, int b, bool c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, bool c) { \ + PCLASS::CBNAME(a,b,c); \ } @@ -483,7 +505,7 @@ public: void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Draw")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", @@ -493,13 +515,13 @@ public: wxPyConstructObject((void*)&rect, "wxRect", 0), row, col, isSelected)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col) { wxSize rval; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) { PyObject* ro; wxSize* ptr; @@ -515,14 +537,14 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } wxGridCellRenderer *Clone() const { wxGridCellRenderer* rval = NULL; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Clone")) { PyObject* ro; wxGridCellRenderer* ptr; @@ -533,7 +555,7 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -593,6 +615,27 @@ public: }; +class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer +{ +public: + wxGridCellDateTimeRenderer(wxString outformat = "%c", + wxString informat = "%c"); +}; + + +class wxGridCellEnumRenderer : public wxGridCellStringRenderer +{ +public: + wxGridCellEnumRenderer( const wxString& choices = "" ); +}; + + +class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer +{ +public: + wxGridCellAutoWrapStringRenderer(); +}; + //--------------------------------------------------------------------------- // wxGridCellEditor is an ABC, and several derived classes are available. @@ -637,7 +680,7 @@ public: wxPyGridCellEditor() : wxGridCellEditor() {} void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Create")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", @@ -645,37 +688,37 @@ public: id, wxPyConstructObject((void*)evtHandler, "wxEvtHandler", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void BeginEdit(int row, int col, wxGrid* grid) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, wxPyConstructObject((void*)grid, "wxGrid", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } bool EndEdit(int row, int col, wxGrid* grid) { bool rv = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "EndEdit")) { rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, wxPyConstructObject((void*)grid, "wxGrid", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rv; } wxGridCellEditor*Clone() const { wxGridCellEditor* rval = NULL; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Clone")) { PyObject* ro; wxGridCellEditor* ptr; @@ -686,20 +729,21 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } void Show(bool show, wxGridCellAttr *attr) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "Show")) + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, wxPyConstructObject((void*)attr, "wxGridCellAttr", 0))); - else + wxPyEndBlockThreads(state); + if (! found) wxGridCellEditor::Show(show, attr); - wxPySaveThread(doSave); } void base_Show(bool show, wxGridCellAttr *attr) { wxGridCellEditor::Show(show, attr); @@ -707,15 +751,16 @@ public: void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "PaintBackground")) + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", wxPyConstructObject((void*)&rectCell, "wxRect", 0), wxPyConstructObject((void*)attr, "wxGridCellAttr", 0))); - else + wxPyEndBlockThreads(state); + if (! found) wxGridCellEditor::PaintBackground(rectCell, attr); - wxPySaveThread(doSave); } void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { wxGridCellEditor::PaintBackground(rectCell, attr); @@ -803,6 +848,22 @@ public: bool allowOthers = FALSE); }; + +class wxGridCellEnumEditor : public wxGridCellChoiceEditor +{ +public: + wxGridCellEnumEditor( const wxString& choices = "" ); +}; + + +class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor +{ +public: + wxGridCellAutoWrapStringEditor(); +}; + + + //--------------------------------------------------------------------------- @@ -1003,7 +1064,7 @@ public: wxString GetValue(int row, int col) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxString rval; if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; @@ -1015,15 +1076,15 @@ public: Py_DECREF(str); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } void SetValue(int row, int col, const wxString& val) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str())); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } @@ -1031,7 +1092,7 @@ public: // the GetValue and SetValue python methods. long GetValueAsLong( int row, int col ) { long rval = 0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; PyObject* num; @@ -1045,13 +1106,13 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } double GetValueAsDouble( int row, int col ) { double rval = 0.0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; PyObject* num; @@ -1065,7 +1126,7 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -1074,19 +1135,19 @@ public: } void SetValueAsLong( int row, int col, long value ) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void SetValueAsDouble( int row, int col, double value ) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void SetValueAsBool( int row, int col, bool value ) { diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 131ed8b56d..c9994a4cfb 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -101,7 +101,8 @@ void WXDLLEXPORT wxEntryCleanup(); #ifdef WXP_WITH_THREAD -PyThreadState* wxPyEventThreadState = NULL; +//PyThreadState* wxPyEventThreadState = NULL; +PyInterpreterState* wxPyInterpreter = NULL; #endif @@ -117,7 +118,8 @@ void __wxPreStart() #ifdef WXP_WITH_THREAD PyEval_InitThreads(); - wxPyEventThreadState = PyThreadState_Get(); // PyThreadState_New(PyThreadState_Get()->interp); +// wxPyEventThreadState = PyThreadState_Get(); // PyThreadState_New(PyThreadState_Get()->interp); + wxPyInterpreter = PyThreadState_Get()->interp; #endif // Bail out if there is already windows created. This means that the @@ -374,41 +376,70 @@ PyObject* wxPyConstructObject(void* ptr, //--------------------------------------------------------------------------- -static PyThreadState* myPyThreadState_Get() { - PyThreadState* current; - current = PyThreadState_Swap(NULL); - PyThreadState_Swap(current); - return current; -} - - -bool wxPyRestoreThread() { - // NOTE: The Python API docs state that if a thread already has the - // interpreter lock and calls PyEval_RestoreThread again a deadlock - // occurs, so I put in this code as a guard condition since there are - // many possibilites for nested events and callbacks in wxPython. If - // The current thread is our thread, then we can assume that we - // already have the lock. (I hope!) - // +// static PyThreadState* myPyThreadState_Get() { +// PyThreadState* current; +// current = PyThreadState_Swap(NULL); +// PyThreadState_Swap(current); +// return current; +// } + + +// bool wxPyRestoreThread() { +// // NOTE: The Python API docs state that if a thread already has the +// // interpreter lock and calls PyEval_RestoreThread again a deadlock +// // occurs, so I put in this code as a guard condition since there are +// // many possibilites for nested events and callbacks in wxPython. If +// // The current thread is our thread, then we can assume that we +// // already have the lock. (I hope!) +// // +// #ifdef WXP_WITH_THREAD +// if (wxPyEventThreadState != myPyThreadState_Get()) { +// PyEval_AcquireThread(wxPyEventThreadState); +// return TRUE; +// } +// else +// #endif +// return FALSE; +// } + + +// void wxPySaveThread(bool doSave) { +// #ifdef WXP_WITH_THREAD +// if (doSave) { +// PyEval_ReleaseThread(wxPyEventThreadState); +// } +// #endif +// } + + + +wxPyTState* wxPyBeginBlockThreads() { + wxPyTState* state = NULL; #ifdef WXP_WITH_THREAD - if (wxPyEventThreadState != myPyThreadState_Get()) { - PyEval_AcquireThread(wxPyEventThreadState); - return TRUE; + if (1) { // Can I check if I've already got the lock? + state = new wxPyTState; + PyEval_AcquireLock(); + state->newState = PyThreadState_New(wxPyInterpreter); + state->prevState = PyThreadState_Swap(state->newState); } - else #endif - return FALSE; + return state; } -void wxPySaveThread(bool doSave) { +void wxPyEndBlockThreads(wxPyTState* state) { #ifdef WXP_WITH_THREAD - if (doSave) { - PyEval_ReleaseThread(wxPyEventThreadState); + if (state) { + PyThreadState_Swap(state->prevState); + PyThreadState_Clear(state->newState); + PyEval_ReleaseLock(); + PyThreadState_Delete(state->newState); + delete state; } #endif } + //--------------------------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxObject); @@ -424,9 +455,9 @@ wxPyCallback::wxPyCallback(const wxPyCallback& other) { } wxPyCallback::~wxPyCallback() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_DECREF(m_func); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } @@ -440,7 +471,7 @@ void wxPyCallback::EventThunker(wxEvent& event) { PyObject* tuple; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxString className = event.GetClassInfo()->GetClassName(); if (className == "wxPyEvent") @@ -460,7 +491,7 @@ void wxPyCallback::EventThunker(wxEvent& event) { } else { PyErr_Print(); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } @@ -563,12 +594,12 @@ PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTu void wxPyCBH_delete(wxPyCallbackHelper* cbh) { - bool doSave = wxPyRestoreThread(); if (cbh->m_incRef) { + wxPyTState* state = wxPyBeginBlockThreads(); Py_XDECREF(cbh->m_self); Py_XDECREF(cbh->m_class); + wxPyEndBlockThreads(state); } - wxPySaveThread(doSave); } //--------------------------------------------------------------------------- @@ -585,14 +616,14 @@ wxPyEvtSelfRef::wxPyEvtSelfRef() { } wxPyEvtSelfRef::~wxPyEvtSelfRef() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_cloned) Py_DECREF(m_self); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void wxPyEvtSelfRef::SetSelf(PyObject* self, bool clone) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_cloned) Py_DECREF(m_self); m_self = self; @@ -600,7 +631,7 @@ void wxPyEvtSelfRef::SetSelf(PyObject* self, bool clone) { Py_INCREF(m_self); m_cloned = TRUE; } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } PyObject* wxPyEvtSelfRef::GetSelf() const { @@ -653,9 +684,9 @@ wxPyTimer::wxPyTimer(PyObject* callback) { } wxPyTimer::~wxPyTimer() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_DECREF(func); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void wxPyTimer::Notify() { @@ -663,7 +694,7 @@ void wxPyTimer::Notify() { wxTimer::Notify(); } else { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* result; PyObject* args = Py_BuildValue("()"); @@ -677,7 +708,7 @@ void wxPyTimer::Notify() { PyErr_Print(); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } } @@ -693,7 +724,7 @@ PyObject* wxPy_ConvertList(wxListBase* list, const char* className) { wxObject* wxObj; wxNode* node = list->First(); - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); pyList = PyList_New(0); while (node) { wxObj = node->Data(); @@ -701,7 +732,7 @@ PyObject* wxPy_ConvertList(wxListBase* list, const char* className) { PyList_Append(pyList, pyObj); node = node->Next(); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return pyList; } diff --git a/wxPython/src/helpers.h b/wxPython/src/helpers.h index d4a9ac09bf..1d503a2046 100644 --- a/wxPython/src/helpers.h +++ b/wxPython/src/helpers.h @@ -68,11 +68,21 @@ PyObject* wxPyClassExists(const char* className); PyObject* wxPyMake_wxObject(wxObject* source); void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); -bool wxPyRestoreThread(); -void wxPySaveThread(bool doSave); PyObject* wxPy_ConvertList(wxListBase* list, const char* className); long wxPyGetWinHandle(wxWindow* win); +//---------------------------------------------------------------------- + +struct wxPyTState { + PyThreadState* newState; + PyThreadState* prevState; + + wxPyTState() : newState(NULL), prevState(NULL) {} +}; + + +wxPyTState* wxPyBeginBlockThreads(); +void wxPyEndBlockThreads(wxPyTState* state); //---------------------------------------------------------------------- @@ -229,8 +239,9 @@ struct wxPyCoreAPI { void (*p_SWIG_addvarlink)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)); PyObject* (*p_SWIG_newvarlink)(void); - void (*p_wxPySaveThread)(bool); - bool (*p_wxPyRestoreThread)(); + wxPyTState* (*p_wxPyBeginBlockThreads)(); + void (*p_wxPyEndBlockThreads)(wxPyTState* state); + PyObject* (*p_wxPyConstructObject)(void *, const char *, int); PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className); @@ -325,15 +336,14 @@ public: } ~wxPyUserData() { - bool doSave; #ifdef wxPyUSE_EXPORT - doSave = wxPyCoreAPIPtr->p_wxPyRestoreThread(); + wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); Py_DECREF(m_obj); - wxPyCoreAPIPtr->p_wxPySaveThread(doSave); + wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state); #else - doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_DECREF(m_obj); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); #endif } PyObject* m_obj; @@ -360,17 +370,18 @@ public: void base_##CBNAME(); -#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME() { \ - PCLASS::CBNAME(); \ +#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME() { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(); \ + } \ + void CLASS::base_##CBNAME() { \ + PCLASS::CBNAME(); \ } //--------------------------------------------------------------------------- @@ -382,13 +393,13 @@ public: #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(int a, int b) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + bool rval, found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(int a, int b) { \ @@ -404,12 +415,13 @@ public: #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ - else \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(int a, int b) { \ PCLASS::CBNAME(a,b); \ @@ -424,13 +436,13 @@ public: #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(int a) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + bool rval, found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(int a) { \ @@ -446,11 +458,11 @@ public: #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(int a) { \ bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ else rval = FALSE; \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } @@ -462,20 +474,21 @@ public: void base_##CBNAME(wxDC& a); -#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME(wxDC& a) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME(wxDC& a) { \ - PCLASS::CBNAME(a); \ +#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(wxDC& a) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a); \ + } \ + void CLASS::base_##CBNAME(wxDC& a) { \ + PCLASS::CBNAME(a); \ } @@ -489,15 +502,16 @@ public: #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(wxDC& a, bool b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxDC& a, bool b) { \ PCLASS::CBNAME(a, b); \ @@ -512,15 +526,16 @@ public: #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(wxDC& a, bool b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxDC& a, bool b) { \ PCLASS::CBNAME(a, b); \ @@ -533,17 +548,18 @@ public: void base_##CBNAME(double a, double b); -#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME(double a, double b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ - else \ - PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME(double a, double b) { \ - PCLASS::CBNAME(a, b); \ +#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(double a, double b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a, b); \ + } \ + void CLASS::base_##CBNAME(double a, double b) { \ + PCLASS::CBNAME(a, b); \ } //--------------------------------------------------------------------------- @@ -555,13 +571,14 @@ public: #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(double a, double b, int c, int d) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ a,b,c,d)); \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ PCLASS::CBNAME(a, b, c, d); \ @@ -569,22 +586,23 @@ public: //--------------------------------------------------------------------------- -#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ +#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); #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 (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d, e, f); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ PCLASS::CBNAME(a, b, c, d, e, f); \ @@ -599,16 +617,17 @@ public: #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ - bool doSave = wxPyRestoreThread(); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ bool rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a, b, c, d, e, f); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ @@ -624,13 +643,14 @@ public: #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \ (int)a,b,c,d,e)); \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d, e); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ PCLASS::CBNAME(a, b, c, d, e); \ @@ -638,22 +658,23 @@ public: //--------------------------------------------------------------------------- -#define DEC_PYCALLBACK__DC4DBL(CBNAME) \ +#define DEC_PYCALLBACK__DC4DBL(CBNAME) \ void CBNAME(wxDC& a, double b, double c, double d, double e); \ void base_##CBNAME(wxDC& a, double b, double c, double d, double e); #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d, e); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ PCLASS::CBNAME(a, b, c, d, e); \ @@ -666,20 +687,21 @@ public: void base_##CBNAME(wxDC& a, bool b); -#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME(wxDC& a, bool b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(&a); \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME(wxDC& a, bool b) { \ - PCLASS::CBNAME(a, b); \ +#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(wxDC& a, bool b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a, b); \ + } \ + void CLASS::base_##CBNAME(wxDC& a, bool b) { \ + PCLASS::CBNAME(a, b); \ } //--------------------------------------------------------------------------- @@ -692,15 +714,16 @@ public: #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \ int e, int f) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d, e, f); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \ int e, int f) { \ @@ -716,15 +739,16 @@ 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 (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(a); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \ Py_DECREF(obj); \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d, e); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \ int d, int e) { \ @@ -738,17 +762,18 @@ public: void base_##CBNAME(double a, double b, int c); -#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME(double a, double b, int c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ - else \ - PCLASS::CBNAME(a, b, c); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME(double a, double b, int c) { \ - PCLASS::CBNAME(a, b, c); \ +#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(double a, double b, int c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a, b, c); \ + } \ + void CLASS::base_##CBNAME(double a, double b, int c) { \ + PCLASS::CBNAME(a, b, c); \ } //--------------------------------------------------------------------------- @@ -760,12 +785,13 @@ public: #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(bool a, double b, double c, int d) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d)); \ - else \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ + wxPyEndBlockThreads(state); \ + if (! found) \ PCLASS::CBNAME(a, b, c, d); \ - wxPySaveThread(doSave); \ } \ void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ PCLASS::CBNAME(a, b, c, d); \ @@ -779,17 +805,18 @@ public: void base_##CBNAME(const wxString& a); -#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ - void CLASS::CBNAME(const wxString& a) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ - else \ - PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - } \ - void CLASS::base_##CBNAME(const wxString& a) { \ - PCLASS::CBNAME(a); \ +#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(const wxString& a) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a); \ + } \ + void CLASS::base_##CBNAME(const wxString& a) { \ + PCLASS::CBNAME(a); \ } //--------------------------------------------------------------------------- @@ -802,12 +829,13 @@ public: #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(const wxString& a) { \ bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ - else \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(const wxString& a) { \ @@ -819,15 +847,15 @@ public: #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \ bool CBNAME(const wxString& a); \ -#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ - bool CLASS::CBNAME(const wxString& a) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ +#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ + bool CLASS::CBNAME(const wxString& a) { \ + bool rval; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ + wxPyEndBlockThreads(state); \ + return rval; \ + } \ //--------------------------------------------------------------------------- @@ -837,17 +865,17 @@ public: #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \ wxString CLASS::CBNAME(const wxString& a) { \ wxString rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str())); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\ if (ro) { \ PyObject* str = PyObject_Str(ro); \ rval = PyString_AsString(str); \ Py_DECREF(ro); Py_DECREF(str); \ } \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } \ @@ -859,8 +887,8 @@ public: #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \ wxString CLASS::CBNAME(const wxString& a,int b) { \ wxString rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ PyObject* ro; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \ if (ro) { \ @@ -869,7 +897,7 @@ public: Py_DECREF(ro); Py_DECREF(str); \ } \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } \ @@ -883,13 +911,14 @@ public: #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(const wxString& a, const wxString& b) { \ bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \ a.c_str(), b.c_str())); \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \ @@ -906,19 +935,20 @@ public: #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \ wxString CLASS::CBNAME() { \ wxString rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ if (ro) { \ PyObject* str = PyObject_Str(ro); \ rval = PyString_AsString(str); \ Py_DECREF(ro); Py_DECREF(str); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxString CLASS::base_##CBNAME() { \ @@ -934,17 +964,17 @@ public: #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \ wxString CLASS::CBNAME() { \ wxString rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ if (ro) { \ PyObject* str = PyObject_Str(ro); \ rval = PyString_AsString(str); \ Py_DECREF(ro); Py_DECREF(str); \ } \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } @@ -957,13 +987,13 @@ public: #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(const wxHtmlTag& a) { \ bool rval = FALSE; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ Py_DECREF(obj); \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } @@ -975,10 +1005,10 @@ public: #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - wxPySaveThread(doSave); \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ } //--------------------------------------------------------------------------- @@ -990,18 +1020,18 @@ public: #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \ wxSize CLASS::CBNAME() { \ wxSize rval(0,0); \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ PyObject* ro; \ wxSize* ptr; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ if (ro) { \ if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ rval = *ptr; \ Py_DECREF(ro); \ } \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } @@ -1012,22 +1042,23 @@ public: bool base_##CBNAME(wxWindow* a); -#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ - bool CLASS::CBNAME(wxWindow* a) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyMake_wxObject(a); \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ - Py_DECREF(obj); \ - } \ - else \ - rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool CLASS::base_##CBNAME(wxWindow* a) { \ - return PCLASS::CBNAME(a); \ +#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ + bool CLASS::CBNAME(wxWindow* a) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(a); \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + bool CLASS::base_##CBNAME(wxWindow* a) { \ + return PCLASS::CBNAME(a); \ } //--------------------------------------------------------------------------- @@ -1037,41 +1068,43 @@ public: bool base_##CBNAME(); -#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ - bool CLASS::CBNAME() { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - rval = PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool CLASS::base_##CBNAME() { \ - return PCLASS::CBNAME(); \ +#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ + bool CLASS::CBNAME() { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(); \ + return rval; \ + } \ + bool CLASS::base_##CBNAME() { \ + return PCLASS::CBNAME(); \ } //--------------------------------------------------------------------------- -#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ - wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ +#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ + wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def); -#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ - wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ - bool doSave = wxPyRestoreThread(); \ - int rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ +#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ + wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + int rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ - else \ - rval = PCLASS::CBNAME(a, b, c); \ - wxPySaveThread(doSave); \ - return (wxDragResult)rval; \ - } \ - wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ - return PCLASS::CBNAME(a, b, c); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b, c); \ + return (wxDragResult)rval; \ + } \ + wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ + return PCLASS::CBNAME(a, b, c); \ } //--------------------------------------------------------------------------- @@ -1081,12 +1114,12 @@ public: #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \ wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \ - bool doSave = wxPyRestoreThread(); \ + wxPyTState* state = wxPyBeginBlockThreads(); \ wxFSFile* rval=0; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ PyObject* ro; \ - PyObject* obj = wxPyMake_wxObject(&a); \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)", \ + PyObject* obj = wxPyMake_wxObject(&a); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\ obj, b.c_str())); \ if (ro) { \ SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \ @@ -1094,7 +1127,7 @@ public: } \ Py_DECREF(obj); \ } \ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ }; @@ -1107,13 +1140,14 @@ public: #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(wxDragResult a) { \ - bool doSave = wxPyRestoreThread(); \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ bool rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ - else \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ bool CLASS::base_##CBNAME(wxDragResult a) { \ @@ -1128,11 +1162,11 @@ public: #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \ wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ - bool doSave = wxPyRestoreThread(); \ + wxPyTState* state = wxPyBeginBlockThreads(); \ int rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return (wxDragResult)rval; \ } \ @@ -1145,10 +1179,10 @@ public: #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \ bool CLASS::CBNAME(int a, int b, const wxString& c) { \ bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ - wxPySaveThread(doSave); \ + wxPyEndBlockThreads(state); \ return rval; \ } \ @@ -1162,12 +1196,13 @@ public: #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \ size_t CLASS::CBNAME() { \ size_t rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ return rval; \ } \ size_t CLASS::base_##CBNAME() { \ @@ -1184,8 +1219,9 @@ public: #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \ wxDataFormat CLASS::CBNAME(size_t a) { \ wxDataFormat rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ wxDataFormat* ptr; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ @@ -1195,9 +1231,9 @@ public: Py_DECREF(ro); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxDataFormat CLASS::base_##CBNAME(size_t a) { \ @@ -1211,20 +1247,21 @@ 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 (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ - Py_DECREF(obj); \ - } \ - 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 found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a); \ + } \ + void CLASS::base_##CBNAME(const Type& a) { \ + PCLASS::CBNAME(a); \ } @@ -1235,20 +1272,21 @@ public: void base_##CBNAME(Type& a); -#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \ - void CLASS::CBNAME(Type& a) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ - Py_DECREF(obj); \ - } \ - 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 found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a); \ + } \ + void CLASS::base_##CBNAME(Type& a) { \ + PCLASS::CBNAME(a); \ } //--------------------------------------------------------------------------- @@ -1258,22 +1296,23 @@ 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 (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ - rv = wxPyCBH_callCallback(m_myInst, 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); \ +#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \ + bool CLASS::CBNAME(Type& a) { \ + bool rv; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ + rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rv = PCLASS::CBNAME(a); \ + return rv; \ + } \ + bool CLASS::base_##CBNAME(Type& a) { \ + return PCLASS::CBNAME(a); \ } //--------------------------------------------------------------------------- @@ -1286,8 +1325,9 @@ public: #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \ wxString CLASS::CBNAME(long a, long b) const { \ wxString rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ if (ro) { \ @@ -1296,9 +1336,9 @@ public: Py_DECREF(ro); Py_DECREF(str); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxString CLASS::base_##CBNAME(long a, long b) const { \ @@ -1315,8 +1355,9 @@ public: #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \ int CLASS::CBNAME(long a) const { \ int rval=-1; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ if (ro) { \ @@ -1324,9 +1365,9 @@ public: Py_DECREF(ro); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ int CLASS::base_##CBNAME(long a) const { \ @@ -1344,8 +1385,9 @@ public: #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \ wxListItemAttr *CLASS::CBNAME(long a) const { \ wxListItemAttr *rval = NULL; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ wxListItemAttr* ptr; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ @@ -1355,9 +1397,9 @@ public: Py_DECREF(ro); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxListItemAttr *CLASS::base_##CBNAME(long a) { \ @@ -1367,7 +1409,3 @@ public: //--------------------------------------------------------------------------- #endif - - - - diff --git a/wxPython/src/html.i b/wxPython/src/html.i index 17665e0d4c..04932f374e 100644 --- a/wxPython/src/html.i +++ b/wxPython/src/html.i @@ -273,25 +273,25 @@ public: } void OnExit() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); 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); + wxPyEndBlockThreads(state); }; void FillHandlersTable(wxHtmlWinParser *parser) { // Wave our magic wand... (if it works it's a miracle! ;-) // First, make a new instance of the tag handler - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arg = Py_BuildValue("()"); PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL); Py_DECREF(arg); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); // now figure out where it's C++ object is... wxPyHtmlWinTagHandler* thPtr; @@ -431,15 +431,16 @@ IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "OnLinkClicked")) { + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked)"))) { PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo", 0); wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); Py_DECREF(obj); } - else + wxPyEndBlockThreads(state); + if (! found) wxHtmlWindow::OnLinkClicked(link); - wxPySaveThread(doSave); } void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { wxHtmlWindow::OnLinkClicked(link); diff --git a/wxPython/src/misc.i b/wxPython/src/misc.i index ddf5e91558..11ed0f1e6f 100644 --- a/wxPython/src/misc.i +++ b/wxPython/src/misc.i @@ -315,13 +315,13 @@ public: dest = reg1.GetBox(); if (dest != wxRect(0,0,0,0)) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxRect* newRect = new wxRect(dest); obj = wxPyConstructObject((void*)newRect, "wxRect"); PyObject* one = PyInt_FromLong(1); PyObject_SetAttrString(obj, "thisown", one); Py_DECREF(one); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return obj; } Py_INCREF(Py_None); diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index 192e87922d..ece14692a1 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -659,6 +659,7 @@ public: }; IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); + %} diff --git a/wxPython/src/msw/clip_dnd.cpp b/wxPython/src/msw/clip_dnd.cpp index 760a1b57e6..3b38150b0d 100644 --- a/wxPython/src/msw/clip_dnd.cpp +++ b/wxPython/src/msw/clip_dnd.cpp @@ -119,7 +119,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { // C++ version. bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetDataHere")) { PyObject* ro; ro = m_myInst.callCallbackObj(Py_BuildValue("()")); @@ -130,7 +130,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) { Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -138,13 +138,13 @@ bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) { // For this one we simply need to make a string from buf and len // and send it to the Python method. bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("SetData")) { PyObject* data = PyString_FromStringAndSize((char*)buf, len); rval = m_myInst.callCallback(Py_BuildValue("(O)", data)); Py_DECREF(data); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } // Create a new class for wxPython to use @@ -176,7 +176,7 @@ public: wxBitmap wxPyBitmapDataObject::GetBitmap() { wxBitmap* rval = &wxNullBitmap; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("GetBitmap")) { PyObject* ro; wxBitmap* ptr; @@ -187,17 +187,17 @@ wxBitmap wxPyBitmapDataObject::GetBitmap() { Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return *rval; } void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (m_myInst.findCallback("SetBitmap")) { m_myInst.callCallback(Py_BuildValue("(O)", wxPyConstructObject((void*)&bitmap, "wxBitmap"))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } // See below in the init function... @@ -293,7 +293,7 @@ public: bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) { bool rval = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* list = PyList_New(0); for (size_t i=0; iGetBoundingRect(item, rect, textOnly)) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxRect* r = new wxRect(rect); PyObject* val = wxPyConstructObject((void*)r, "wxRect"); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return val; } else { diff --git a/wxPython/src/msw/gdi.cpp b/wxPython/src/msw/gdi.cpp index 7fa8794735..f509e9d0fe 100644 --- a/wxPython/src/msw/gdi.cpp +++ b/wxPython/src/msw/gdi.cpp @@ -8363,6 +8363,43 @@ static PyObject *_wrap_wxDC_SetClippingRegion(PyObject *self, PyObject *args, Py return _resultobj; } +#define wxDC_SetClippingRegionAsRegion(_swigobj,_swigarg0) (_swigobj->SetClippingRegion(_swigarg0)) +static PyObject *_wrap_wxDC_SetClippingRegionAsRegion(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxDC * _arg0; + wxRegion * _arg1; + PyObject * _argo0 = 0; + PyObject * _argo1 = 0; + char *_kwnames[] = { "self","region", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxDC_SetClippingRegionAsRegion",_kwnames,&_argo0,&_argo1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxDC_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxDC_SetClippingRegionAsRegion. Expected _wxDC_p."); + return NULL; + } + } + if (_argo1) { + if (_argo1 == Py_None) { _arg1 = NULL; } + else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxRegion_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxDC_SetClippingRegionAsRegion. Expected _wxRegion_p."); + return NULL; + } + } +{ + wxPy_BEGIN_ALLOW_THREADS; + wxDC_SetClippingRegionAsRegion(_arg0,*_arg1); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + #define wxDC_SetPalette(_swigobj,_swigarg0) (_swigobj->SetPalette(_swigarg0)) static PyObject *_wrap_wxDC_SetPalette(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -11492,6 +11529,7 @@ static PyMethodDef gdicMethods[] = { { "wxDC_SetFont", (PyCFunction) _wrap_wxDC_SetFont, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetBrush", (PyCFunction) _wrap_wxDC_SetBrush, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetPalette", (PyCFunction) _wrap_wxDC_SetPalette, METH_VARARGS | METH_KEYWORDS }, + { "wxDC_SetClippingRegionAsRegion", (PyCFunction) _wrap_wxDC_SetClippingRegionAsRegion, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetClippingRegion", (PyCFunction) _wrap_wxDC_SetClippingRegion, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetBackgroundMode", (PyCFunction) _wrap_wxDC_SetBackgroundMode, METH_VARARGS | METH_KEYWORDS }, { "wxDC_SetBackground", (PyCFunction) _wrap_wxDC_SetBackground, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/gdi.py b/wxPython/src/msw/gdi.py index dc426ee230..c1624dfe47 100644 --- a/wxPython/src/msw/gdi.py +++ b/wxPython/src/msw/gdi.py @@ -817,6 +817,9 @@ class wxDCPtr(wxObjectPtr): def SetClippingRegion(self, *_args, **_kwargs): val = apply(gdic.wxDC_SetClippingRegion,(self,) + _args, _kwargs) return val + def SetClippingRegionAsRegion(self, *_args, **_kwargs): + val = apply(gdic.wxDC_SetClippingRegionAsRegion,(self,) + _args, _kwargs) + return val def SetPalette(self, *_args, **_kwargs): val = apply(gdic.wxDC_SetPalette,(self,) + _args, _kwargs) return val diff --git a/wxPython/src/msw/grid.cpp b/wxPython/src/msw/grid.cpp index 6c3ee04f4b..b65d674a27 100644 --- a/wxPython/src/msw/grid.cpp +++ b/wxPython/src/msw/grid.cpp @@ -57,6 +57,7 @@ extern PyObject *SWIG_newvarlink(void); #include "export.h" #include +#include static PyObject* t_output_helper(PyObject* target, PyObject* o) { @@ -94,8 +95,9 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME) \ wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ wxGridCellAttr* rval = NULL; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* ro; \ wxGridCellAttr* ptr; \ ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \ @@ -105,9 +107,9 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { Py_DECREF(ro); \ } \ } \ - else \ + wxPyEndBlockThreads(state); \ + if (! found) \ rval = PCLASS::CBNAME(a, b, c); \ - wxPySaveThread(doSave); \ return rval; \ } \ wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ @@ -116,356 +118,376 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { -#define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \ - void CBNAME(wxGridCellAttr *attr, int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ +#define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \ + void CBNAME(wxGridCellAttr *attr, int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool found; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(attr, a, b); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \ - PCLASS::CBNAME(attr, a, b); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(attr, a, b); \ + } \ + void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \ + PCLASS::CBNAME(attr, a, b); \ } -#define PYCALLBACK__GCAINT(PCLASS, CBNAME) \ - void CBNAME(wxGridCellAttr *attr, int val) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ +#define PYCALLBACK__GCAINT(PCLASS, CBNAME) \ + void CBNAME(wxGridCellAttr *attr, int val) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool found; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \ - Py_DECREF(obj); \ - } \ - else \ - PCLASS::CBNAME(attr, val); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(wxGridCellAttr *attr, int val) { \ - PCLASS::CBNAME(attr, val); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(attr, val); \ + } \ + void base_##CBNAME(wxGridCellAttr *attr, int val) { \ + PCLASS::CBNAME(attr, val); \ } -#define PYCALLBACK_INT__pure(CBNAME) \ - int CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - int rval = 0; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - wxPySaveThread(doSave); \ - return rval; \ +#define PYCALLBACK_INT__pure(CBNAME) \ + int CBNAME() { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + int rval = 0; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + return rval; \ } -#define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \ - bool CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - bool rval = 0; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ - wxPySaveThread(doSave); \ - return rval; \ - } - - - -#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \ - wxString CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } \ - wxPySaveThread(doSave); \ - return rval; \ - } - - - -#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \ - void CBNAME(int a, int b, const wxString& c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str())); \ - wxPySaveThread(doSave); \ +#define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \ + bool CBNAME(int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + bool rval = 0; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ + wxPyEndBlockThreads(state); \ + return rval; \ } - - -#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \ - wxString CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - wxString base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a, b); \ - } - - - -#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \ - bool CBNAME(int a, int b, const wxString& c) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str())); \ - else \ - rval = PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(int a, int b, const wxString& c) { \ - return PCLASS::CBNAME(a,b,c); \ - } - - - - -#define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \ - long CBNAME(int a, int b) { \ - long rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - long base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a,b); \ - } - - - -#define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \ - bool CBNAME(int a, int b) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a,b); \ - } - - - -#define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \ - double CBNAME(int a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - double rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyFloat_AsDouble(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a, b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - double base_##CBNAME(int a, int b) { \ - return PCLASS::CBNAME(a, b); \ - } - - - -#define PYCALLBACK__(PCLASS, CBNAME) \ - void CBNAME() { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME() { \ - PCLASS::CBNAME(); \ - } - - - - -#define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \ - bool CBNAME(size_t a, size_t b) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - rval = PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(size_t a, size_t b) { \ - return PCLASS::CBNAME(a,b); \ - } - - - -#define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \ - bool CBNAME(size_t a) { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ - else \ - rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME(size_t a) { \ - return PCLASS::CBNAME(a); \ - } - - - -#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \ - wxString CBNAME(int a) { \ - bool doSave = wxPyRestoreThread(); \ - wxString rval; \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ - PyObject* ro; \ - ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \ - if (ro) { \ - PyObject* str = PyObject_Str(ro); \ - rval = PyString_AsString(str); \ - Py_DECREF(ro); Py_DECREF(str); \ - } \ - } else \ - rval = PCLASS::CBNAME(a); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - wxString base_##CBNAME(int a) { \ - return PCLASS::CBNAME(a); \ + + + +#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \ + wxString CBNAME(int a, int b) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + return rval; \ } -#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \ - void CBNAME(int a, const wxString& c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \ - else \ - PCLASS::CBNAME(a,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, const wxString& c) { \ - PCLASS::CBNAME(a,c); \ +#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \ + void CBNAME(int a, int b, const wxString& c) { \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ + wxPyEndBlockThreads(state); \ } +#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \ + wxString CBNAME(int a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b); \ + return rval; \ + } \ + wxString base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a, b); \ + } + -#define PYCALLBACK_BOOL_(PCLASS, CBNAME) \ - bool CBNAME() { \ - bool rval; \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ - else \ - rval = PCLASS::CBNAME(); \ - wxPySaveThread(doSave); \ - return rval; \ - } \ - bool base_##CBNAME() { \ - return PCLASS::CBNAME(); \ +#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \ + bool CBNAME(int a, int b, const wxString& c) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));\ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b,c); \ + return rval; \ + } \ + bool base_##CBNAME(int a, int b, const wxString& c) { \ + return PCLASS::CBNAME(a,b,c); \ } -#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \ - void CBNAME(size_t a, int b) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ - else \ - PCLASS::CBNAME(a,b); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(size_t a, int b) { \ - PCLASS::CBNAME(a,b); \ + +#define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \ + long CBNAME(int a, int b) { \ + long rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + long base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a,b); \ } +#define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \ + bool CBNAME(int a, int b) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + bool base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a,b); \ + } + -#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \ - void CBNAME(int a, int b, long c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, long c) { \ - PCLASS::CBNAME(a,b,c); \ + +#define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \ + double CBNAME(int a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + double rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyFloat_AsDouble(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b); \ + return rval; \ + } \ + double base_##CBNAME(int a, int b) { \ + return PCLASS::CBNAME(a, b); \ + } + + + +#define PYCALLBACK__(PCLASS, CBNAME) \ + void CBNAME() { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(); \ + } \ + void base_##CBNAME() { \ + PCLASS::CBNAME(); \ + } + + + + +#define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \ + bool CBNAME(size_t a, size_t b) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a,b); \ + return rval; \ + } \ + bool base_##CBNAME(size_t a, size_t b) { \ + return PCLASS::CBNAME(a,b); \ + } + + + +#define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \ + bool CBNAME(size_t a) { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + bool base_##CBNAME(size_t a) { \ + return PCLASS::CBNAME(a); \ } +#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \ + wxString CBNAME(int a) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + wxString rval; \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \ + if (ro) { \ + PyObject* str = PyObject_Str(ro); \ + rval = PyString_AsString(str); \ + Py_DECREF(ro); Py_DECREF(str); \ + } \ + } \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + wxString base_##CBNAME(int a) { \ + return PCLASS::CBNAME(a); \ + } + + -#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \ - void CBNAME(int a, int b, double c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, double c) { \ - PCLASS::CBNAME(a,b,c); \ +#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \ + void CBNAME(int a, const wxString& c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,c); \ + } \ + void base_##CBNAME(int a, const wxString& c) { \ + PCLASS::CBNAME(a,c); \ } -#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \ - void CBNAME(int a, int b, bool c) { \ - bool doSave = wxPyRestoreThread(); \ - if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ - wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ - else \ - PCLASS::CBNAME(a,b,c); \ - wxPySaveThread(doSave); \ - } \ - void base_##CBNAME(int a, int b, bool c) { \ - PCLASS::CBNAME(a,b,c); \ + +#define PYCALLBACK_BOOL_(PCLASS, CBNAME) \ + bool CBNAME() { \ + bool rval; \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + rval = PCLASS::CBNAME(); \ + return rval; \ + } \ + bool base_##CBNAME() { \ + return PCLASS::CBNAME(); \ + } + + + +#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \ + void CBNAME(size_t a, int b) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b); \ + } \ + void base_##CBNAME(size_t a, int b) { \ + PCLASS::CBNAME(a,b); \ + } + + + + +#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \ + void CBNAME(int a, int b, long c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, long c) { \ + PCLASS::CBNAME(a,b,c); \ + } + + + + +#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \ + void CBNAME(int a, int b, double c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, double c) { \ + PCLASS::CBNAME(a,b,c); \ + } + + + +#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \ + void CBNAME(int a, int b, bool c) { \ + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ + wxPyEndBlockThreads(state); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void base_##CBNAME(int a, int b, bool c) { \ + PCLASS::CBNAME(a,b,c); \ } @@ -481,7 +503,7 @@ public: void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Draw")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", @@ -491,13 +513,13 @@ public: wxPyConstructObject((void*)&rect, "wxRect", 0), row, col, isSelected)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col) { wxSize rval; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) { PyObject* ro; wxSize* ptr; @@ -513,14 +535,14 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } wxGridCellRenderer *Clone() const { wxGridCellRenderer* rval = NULL; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Clone")) { PyObject* ro; wxGridCellRenderer* ptr; @@ -531,7 +553,7 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -549,7 +571,7 @@ public: wxPyGridCellEditor() : wxGridCellEditor() {} void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Create")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", @@ -557,37 +579,37 @@ public: id, wxPyConstructObject((void*)evtHandler, "wxEvtHandler", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void BeginEdit(int row, int col, wxGrid* grid) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, wxPyConstructObject((void*)grid, "wxGrid", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } bool EndEdit(int row, int col, wxGrid* grid) { bool rv = FALSE; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "EndEdit")) { rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, wxPyConstructObject((void*)grid, "wxGrid", 0))); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rv; } wxGridCellEditor*Clone() const { wxGridCellEditor* rval = NULL; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "Clone")) { PyObject* ro; wxGridCellEditor* ptr; @@ -598,20 +620,21 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } void Show(bool show, wxGridCellAttr *attr) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "Show")) + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, wxPyConstructObject((void*)attr, "wxGridCellAttr", 0))); - else + wxPyEndBlockThreads(state); + if (! found) wxGridCellEditor::Show(show, attr); - wxPySaveThread(doSave); } void base_Show(bool show, wxGridCellAttr *attr) { wxGridCellEditor::Show(show, attr); @@ -619,15 +642,16 @@ public: void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "PaintBackground")) + bool found; \ + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", wxPyConstructObject((void*)&rectCell, "wxRect", 0), wxPyConstructObject((void*)attr, "wxGridCellAttr", 0))); - else + wxPyEndBlockThreads(state); + if (! found) wxGridCellEditor::PaintBackground(rectCell, attr); - wxPySaveThread(doSave); } void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { wxGridCellEditor::PaintBackground(rectCell, attr); @@ -700,7 +724,7 @@ public: wxString GetValue(int row, int col) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxString rval; if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; @@ -712,15 +736,15 @@ public: Py_DECREF(str); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } void SetValue(int row, int col, const wxString& val) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str())); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } @@ -728,7 +752,7 @@ public: // the GetValue and SetValue python methods. long GetValueAsLong( int row, int col ) { long rval = 0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; PyObject* num; @@ -742,13 +766,13 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } double GetValueAsDouble( int row, int col ) { double rval = 0.0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "GetValue")) { PyObject* ro; PyObject* num; @@ -762,7 +786,7 @@ public: Py_DECREF(ro); } } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return rval; } @@ -771,19 +795,19 @@ public: } void SetValueAsLong( int row, int col, long value ) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void SetValueAsDouble( int row, int col, double value ) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetValue")) { wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value)); } - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } void SetValueAsBool( int row, int col, bool value ) { @@ -1513,6 +1537,194 @@ static PyObject *_wrap_new_wxGridCellBoolRenderer(PyObject *self, PyObject *args return _resultobj; } +static void *SwigwxGridCellDateTimeRendererTowxGridCellStringRenderer(void *ptr) { + wxGridCellDateTimeRenderer *src; + wxGridCellStringRenderer *dest; + src = (wxGridCellDateTimeRenderer *) ptr; + dest = (wxGridCellStringRenderer *) src; + return (void *) dest; +} + +static void *SwigwxGridCellDateTimeRendererTowxGridCellRenderer(void *ptr) { + wxGridCellDateTimeRenderer *src; + wxGridCellRenderer *dest; + src = (wxGridCellDateTimeRenderer *) ptr; + dest = (wxGridCellRenderer *) src; + return (void *) dest; +} + +#define new_wxGridCellDateTimeRenderer(_swigarg0,_swigarg1) (new wxGridCellDateTimeRenderer(_swigarg0,_swigarg1)) +static PyObject *_wrap_new_wxGridCellDateTimeRenderer(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxGridCellDateTimeRenderer * _result; + wxString * _arg0 = (wxString *) &"%c"; + wxString * _arg1 = (wxString *) &"%c"; + PyObject * _obj0 = 0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "outformat","informat", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|OO:new_wxGridCellDateTimeRenderer",_kwnames,&_obj0,&_obj1)) + return NULL; + if (_obj0) +{ +#if PYTHON_API_VERSION >= 1009 + char* tmpPtr; int tmpSize; + if (!PyString_Check(_obj0) && !PyUnicode_Check(_obj0)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + if (PyString_AsStringAndSize(_obj0, &tmpPtr, &tmpSize) == -1) + return NULL; + _arg0 = new wxString(tmpPtr, tmpSize); +#else + if (!PyString_Check(_obj0)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + _arg0 = new wxString(PyString_AS_STRING(_obj0), PyString_GET_SIZE(_obj0)); +#endif +} + if (_obj1) +{ +#if PYTHON_API_VERSION >= 1009 + char* tmpPtr; int tmpSize; + if (!PyString_Check(_obj1) && !PyUnicode_Check(_obj1)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + if (PyString_AsStringAndSize(_obj1, &tmpPtr, &tmpSize) == -1) + return NULL; + _arg1 = new wxString(tmpPtr, tmpSize); +#else + if (!PyString_Check(_obj1)) { + PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); + return NULL; + } + _arg1 = new wxString(PyString_AS_STRING(_obj1), PyString_GET_SIZE(_obj1)); +#endif +} +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxGridCellDateTimeRenderer *)new_wxGridCellDateTimeRenderer(*_arg0,*_arg1); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCellDateTimeRenderer_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } +{ + if (_obj0) + delete _arg0; +} +{ + if (_obj1) + delete _arg1; +} + return _resultobj; +} + +static void *SwigwxGridCellEnumRendererTowxGridCellStringRenderer(void *ptr) { + wxGridCellEnumRenderer *src; + wxGridCellStringRenderer *dest; + src = (wxGridCellEnumRenderer *) ptr; + dest = (wxGridCellStringRenderer *) src; + return (void *) dest; +} + +static void *SwigwxGridCellEnumRendererTowxGridCellRenderer(void *ptr) { + wxGridCellEnumRenderer *src; + wxGridCellRenderer *dest; + src = (wxGridCellEnumRenderer *) ptr; + dest = (wxGridCellRenderer *) src; + return (void *) dest; +} + +#define new_wxGridCellEnumRenderer(_swigarg0) (new wxGridCellEnumRenderer(_swigarg0)) +static PyObject *_wrap_new_wxGridCellEnumRenderer(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxGridCellEnumRenderer * _result; + wxString * _arg0 = (wxString *) &""; + PyObject * _obj0 = 0; + char *_kwnames[] = { "choices", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|O:new_wxGridCellEnumRenderer",_kwnames,&_obj0)) + return NULL; + if (_obj0) +{ + _arg0 = wxString_LIST_helper(_obj0); + if (_arg0 == NULL) { + return NULL; + } +} +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxGridCellEnumRenderer *)new_wxGridCellEnumRenderer(*_arg0); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCellEnumRenderer_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } +{ + delete [] _arg0; +} + return _resultobj; +} + +static void *SwigwxGridCellAutoWrapStringRendererTowxGridCellStringRenderer(void *ptr) { + wxGridCellAutoWrapStringRenderer *src; + wxGridCellStringRenderer *dest; + src = (wxGridCellAutoWrapStringRenderer *) ptr; + dest = (wxGridCellStringRenderer *) src; + return (void *) dest; +} + +static void *SwigwxGridCellAutoWrapStringRendererTowxGridCellRenderer(void *ptr) { + wxGridCellAutoWrapStringRenderer *src; + wxGridCellRenderer *dest; + src = (wxGridCellAutoWrapStringRenderer *) ptr; + dest = (wxGridCellRenderer *) src; + return (void *) dest; +} + +#define new_wxGridCellAutoWrapStringRenderer() (new wxGridCellAutoWrapStringRenderer()) +static PyObject *_wrap_new_wxGridCellAutoWrapStringRenderer(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxGridCellAutoWrapStringRenderer * _result; + char *_kwnames[] = { NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,":new_wxGridCellAutoWrapStringRenderer",_kwnames)) + return NULL; +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxGridCellAutoWrapStringRenderer *)new_wxGridCellAutoWrapStringRenderer(); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCellAutoWrapStringRenderer_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + #define wxGridCellEditor_IsCreated(_swigobj) (_swigobj->IsCreated()) static PyObject *_wrap_wxGridCellEditor_IsCreated(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -2814,6 +3026,102 @@ static PyObject *_wrap_new_wxGridCellChoiceEditor(PyObject *self, PyObject *args return _resultobj; } +static void *SwigwxGridCellEnumEditorTowxGridCellChoiceEditor(void *ptr) { + wxGridCellEnumEditor *src; + wxGridCellChoiceEditor *dest; + src = (wxGridCellEnumEditor *) ptr; + dest = (wxGridCellChoiceEditor *) src; + return (void *) dest; +} + +static void *SwigwxGridCellEnumEditorTowxGridCellEditor(void *ptr) { + wxGridCellEnumEditor *src; + wxGridCellEditor *dest; + src = (wxGridCellEnumEditor *) ptr; + dest = (wxGridCellEditor *) src; + return (void *) dest; +} + +#define new_wxGridCellEnumEditor(_swigarg0) (new wxGridCellEnumEditor(_swigarg0)) +static PyObject *_wrap_new_wxGridCellEnumEditor(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxGridCellEnumEditor * _result; + wxString * _arg0 = (wxString *) &""; + PyObject * _obj0 = 0; + char *_kwnames[] = { "choices", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|O:new_wxGridCellEnumEditor",_kwnames,&_obj0)) + return NULL; + if (_obj0) +{ + _arg0 = wxString_LIST_helper(_obj0); + if (_arg0 == NULL) { + return NULL; + } +} +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxGridCellEnumEditor *)new_wxGridCellEnumEditor(*_arg0); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCellEnumEditor_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } +{ + delete [] _arg0; +} + return _resultobj; +} + +static void *SwigwxGridCellAutoWrapStringEditorTowxGridCellTextEditor(void *ptr) { + wxGridCellAutoWrapStringEditor *src; + wxGridCellTextEditor *dest; + src = (wxGridCellAutoWrapStringEditor *) ptr; + dest = (wxGridCellTextEditor *) src; + return (void *) dest; +} + +static void *SwigwxGridCellAutoWrapStringEditorTowxGridCellEditor(void *ptr) { + wxGridCellAutoWrapStringEditor *src; + wxGridCellEditor *dest; + src = (wxGridCellAutoWrapStringEditor *) ptr; + dest = (wxGridCellEditor *) src; + return (void *) dest; +} + +#define new_wxGridCellAutoWrapStringEditor() (new wxGridCellAutoWrapStringEditor()) +static PyObject *_wrap_new_wxGridCellAutoWrapStringEditor(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxGridCellAutoWrapStringEditor * _result; + char *_kwnames[] = { NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,":new_wxGridCellAutoWrapStringEditor",_kwnames)) + return NULL; +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (wxGridCellAutoWrapStringEditor *)new_wxGridCellAutoWrapStringEditor(); + + wxPy_END_ALLOW_THREADS; + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxGridCellAutoWrapStringEditor_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + #define new_wxGridCellAttr() (new wxGridCellAttr()) static PyObject *_wrap_new_wxGridCellAttr(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -14002,6 +14310,8 @@ static PyMethodDef gridcMethods[] = { { "wxGridCellAttr_MergeWith", (PyCFunction) _wrap_wxGridCellAttr_MergeWith, METH_VARARGS | METH_KEYWORDS }, { "wxGridCellAttr_Clone", (PyCFunction) _wrap_wxGridCellAttr_Clone, METH_VARARGS | METH_KEYWORDS }, { "new_wxGridCellAttr", (PyCFunction) _wrap_new_wxGridCellAttr, METH_VARARGS | METH_KEYWORDS }, + { "new_wxGridCellAutoWrapStringEditor", (PyCFunction) _wrap_new_wxGridCellAutoWrapStringEditor, METH_VARARGS | METH_KEYWORDS }, + { "new_wxGridCellEnumEditor", (PyCFunction) _wrap_new_wxGridCellEnumEditor, METH_VARARGS | METH_KEYWORDS }, { "new_wxGridCellChoiceEditor", (PyCFunction) _wrap_new_wxGridCellChoiceEditor, METH_VARARGS | METH_KEYWORDS }, { "new_wxGridCellBoolEditor", (PyCFunction) _wrap_new_wxGridCellBoolEditor, METH_VARARGS | METH_KEYWORDS }, { "new_wxGridCellFloatEditor", (PyCFunction) _wrap_new_wxGridCellFloatEditor, METH_VARARGS | METH_KEYWORDS }, @@ -14037,6 +14347,9 @@ static PyMethodDef gridcMethods[] = { { "wxGridCellEditor_SetControl", (PyCFunction) _wrap_wxGridCellEditor_SetControl, METH_VARARGS | METH_KEYWORDS }, { "wxGridCellEditor_GetControl", (PyCFunction) _wrap_wxGridCellEditor_GetControl, METH_VARARGS | METH_KEYWORDS }, { "wxGridCellEditor_IsCreated", (PyCFunction) _wrap_wxGridCellEditor_IsCreated, METH_VARARGS | METH_KEYWORDS }, + { "new_wxGridCellAutoWrapStringRenderer", (PyCFunction) _wrap_new_wxGridCellAutoWrapStringRenderer, METH_VARARGS | METH_KEYWORDS }, + { "new_wxGridCellEnumRenderer", (PyCFunction) _wrap_new_wxGridCellEnumRenderer, METH_VARARGS | METH_KEYWORDS }, + { "new_wxGridCellDateTimeRenderer", (PyCFunction) _wrap_new_wxGridCellDateTimeRenderer, METH_VARARGS | METH_KEYWORDS }, { "new_wxGridCellBoolRenderer", (PyCFunction) _wrap_new_wxGridCellBoolRenderer, METH_VARARGS | METH_KEYWORDS }, { "wxGridCellFloatRenderer_SetPrecision", (PyCFunction) _wrap_wxGridCellFloatRenderer_SetPrecision, METH_VARARGS | METH_KEYWORDS }, { "wxGridCellFloatRenderer_GetPrecision", (PyCFunction) _wrap_wxGridCellFloatRenderer_GetPrecision, METH_VARARGS | METH_KEYWORDS }, @@ -14068,6 +14381,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxEvent","_wxGridSizeEvent",SwigwxGridSizeEventTowxEvent}, { "_wxEvent","_wxGridEvent",SwigwxGridEventTowxEvent}, { "_signed_long","_long",0}, + { "_wxGridCellChoiceEditor","_wxGridCellEnumEditor",SwigwxGridCellEnumEditorTowxGridCellChoiceEditor}, { "_wxPrintQuality","_WXGRIDSELECTIONMODES",0}, { "_wxPrintQuality","_wxCoord",0}, { "_wxPrintQuality","_int",0}, @@ -14107,6 +14421,9 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxCommandEvent","_wxGridSizeEvent",SwigwxGridSizeEventTowxCommandEvent}, { "_wxCommandEvent","_wxGridEvent",SwigwxGridEventTowxCommandEvent}, { "_char","_wxChar",0}, + { "_wxGridCellStringRenderer","_wxGridCellAutoWrapStringRenderer",SwigwxGridCellAutoWrapStringRendererTowxGridCellStringRenderer}, + { "_wxGridCellStringRenderer","_wxGridCellEnumRenderer",SwigwxGridCellEnumRendererTowxGridCellStringRenderer}, + { "_wxGridCellStringRenderer","_wxGridCellDateTimeRenderer",SwigwxGridCellDateTimeRendererTowxGridCellStringRenderer}, { "_wxGridCellStringRenderer","_wxGridCellFloatRenderer",SwigwxGridCellFloatRendererTowxGridCellStringRenderer}, { "_wxGridCellStringRenderer","_wxGridCellNumberRenderer",SwigwxGridCellNumberRendererTowxGridCellStringRenderer}, { "_struct_wxNativeFontInfo","_wxNativeFontInfo",0}, @@ -14136,6 +14453,8 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_signed_int","_EBool",0}, { "_signed_int","_wxWindowID",0}, { "_signed_int","_int",0}, + { "_wxGridCellEditor","_wxGridCellAutoWrapStringEditor",SwigwxGridCellAutoWrapStringEditorTowxGridCellEditor}, + { "_wxGridCellEditor","_wxGridCellEnumEditor",SwigwxGridCellEnumEditorTowxGridCellEditor}, { "_wxGridCellEditor","_wxGridCellChoiceEditor",SwigwxGridCellChoiceEditorTowxGridCellEditor}, { "_wxGridCellEditor","_wxGridCellBoolEditor",SwigwxGridCellBoolEditorTowxGridCellEditor}, { "_wxGridCellEditor","_wxGridCellFloatEditor",SwigwxGridCellFloatEditorTowxGridCellEditor}, @@ -14209,11 +14528,15 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { { "_wxCoord","_size_t",0}, { "_wxCoord","_time_t",0}, { "_wxCoord","_wxPrintQuality",0}, + { "_wxGridCellRenderer","_wxGridCellAutoWrapStringRenderer",SwigwxGridCellAutoWrapStringRendererTowxGridCellRenderer}, + { "_wxGridCellRenderer","_wxGridCellEnumRenderer",SwigwxGridCellEnumRendererTowxGridCellRenderer}, + { "_wxGridCellRenderer","_wxGridCellDateTimeRenderer",SwigwxGridCellDateTimeRendererTowxGridCellRenderer}, { "_wxGridCellRenderer","_wxGridCellBoolRenderer",SwigwxGridCellBoolRendererTowxGridCellRenderer}, { "_wxGridCellRenderer","_wxGridCellFloatRenderer",SwigwxGridCellFloatRendererTowxGridCellRenderer}, { "_wxGridCellRenderer","_wxGridCellNumberRenderer",SwigwxGridCellNumberRendererTowxGridCellRenderer}, { "_wxGridCellRenderer","_wxGridCellStringRenderer",SwigwxGridCellStringRendererTowxGridCellRenderer}, { "_wxGridCellRenderer","_wxPyGridCellRenderer",SwigwxPyGridCellRendererTowxGridCellRenderer}, + { "_wxGridCellTextEditor","_wxGridCellAutoWrapStringEditor",SwigwxGridCellAutoWrapStringEditorTowxGridCellTextEditor}, { "_wxGridCellTextEditor","_wxGridCellFloatEditor",SwigwxGridCellFloatEditorTowxGridCellTextEditor}, { "_wxGridCellTextEditor","_wxGridCellNumberEditor",SwigwxGridCellNumberEditorTowxGridCellTextEditor}, { "_wxEvtHandler","_wxGrid",SwigwxGridTowxEvtHandler}, diff --git a/wxPython/src/msw/grid.py b/wxPython/src/msw/grid.py index 04c9de468f..69fa227da9 100644 --- a/wxPython/src/msw/grid.py +++ b/wxPython/src/msw/grid.py @@ -185,6 +185,48 @@ class wxGridCellBoolRenderer(wxGridCellBoolRendererPtr): +class wxGridCellDateTimeRendererPtr(wxGridCellStringRendererPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def __repr__(self): + return "" % (self.this,) +class wxGridCellDateTimeRenderer(wxGridCellDateTimeRendererPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(gridc.new_wxGridCellDateTimeRenderer,_args,_kwargs) + self.thisown = 1 + + + + +class wxGridCellEnumRendererPtr(wxGridCellStringRendererPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def __repr__(self): + return "" % (self.this,) +class wxGridCellEnumRenderer(wxGridCellEnumRendererPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(gridc.new_wxGridCellEnumRenderer,_args,_kwargs) + self.thisown = 1 + + + + +class wxGridCellAutoWrapStringRendererPtr(wxGridCellStringRendererPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def __repr__(self): + return "" % (self.this,) +class wxGridCellAutoWrapStringRenderer(wxGridCellAutoWrapStringRendererPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(gridc.new_wxGridCellAutoWrapStringRenderer,_args,_kwargs) + self.thisown = 1 + + + + class wxGridCellEditorPtr : def __init__(self,this): self.this = this @@ -371,6 +413,34 @@ class wxGridCellChoiceEditor(wxGridCellChoiceEditorPtr): +class wxGridCellEnumEditorPtr(wxGridCellChoiceEditorPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def __repr__(self): + return "" % (self.this,) +class wxGridCellEnumEditor(wxGridCellEnumEditorPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(gridc.new_wxGridCellEnumEditor,_args,_kwargs) + self.thisown = 1 + + + + +class wxGridCellAutoWrapStringEditorPtr(wxGridCellTextEditorPtr): + def __init__(self,this): + self.this = this + self.thisown = 0 + def __repr__(self): + return "" % (self.this,) +class wxGridCellAutoWrapStringEditor(wxGridCellAutoWrapStringEditorPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(gridc.new_wxGridCellAutoWrapStringEditor,_args,_kwargs) + self.thisown = 1 + + + + class wxGridCellAttrPtr : Any = gridc.wxGridCellAttr_Any Default = gridc.wxGridCellAttr_Default diff --git a/wxPython/src/msw/html.cpp b/wxPython/src/msw/html.cpp index 02c5bd6f3d..f292a4d27d 100644 --- a/wxPython/src/msw/html.cpp +++ b/wxPython/src/msw/html.cpp @@ -148,25 +148,25 @@ public: } void OnExit() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); 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); + wxPyEndBlockThreads(state); }; void FillHandlersTable(wxHtmlWinParser *parser) { // Wave our magic wand... (if it works it's a miracle! ;-) // First, make a new instance of the tag handler - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arg = Py_BuildValue("()"); PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL); Py_DECREF(arg); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); // now figure out where it's C++ object is... wxPyHtmlWinTagHandler* thPtr; @@ -213,15 +213,16 @@ IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { - bool doSave = wxPyRestoreThread(); - if (wxPyCBH_findCallback(m_myInst, "OnLinkClicked")) { + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked)"))) { PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo", 0); wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); Py_DECREF(obj); } - else + wxPyEndBlockThreads(state); + if (! found) wxHtmlWindow::OnLinkClicked(link); - wxPySaveThread(doSave); } void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { wxHtmlWindow::OnLinkClicked(link); diff --git a/wxPython/src/msw/misc.cpp b/wxPython/src/msw/misc.cpp index 15e9210546..1c91992194 100644 --- a/wxPython/src/msw/misc.cpp +++ b/wxPython/src/msw/misc.cpp @@ -105,13 +105,13 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { dest = reg1.GetBox(); if (dest != wxRect(0,0,0,0)) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); wxRect* newRect = new wxRect(dest); obj = wxPyConstructObject((void*)newRect, "wxRect"); PyObject* one = PyInt_FromLong(1); PyObject_SetAttrString(obj, "thisown", one); Py_DECREF(one); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return obj; } Py_INCREF(Py_None); diff --git a/wxPython/src/msw/misc2.cpp b/wxPython/src/msw/misc2.cpp index 36ced95d6e..21631395cc 100644 --- a/wxPython/src/msw/misc2.cpp +++ b/wxPython/src/msw/misc2.cpp @@ -175,6 +175,7 @@ public: IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); + #if !wxUSE_JOYSTICK && !defined(__WXMSW__) // A C++ stub class for wxJoystick for platforms that don't have it. class wxJoystick : public wxObject { diff --git a/wxPython/src/msw/printfw.cpp b/wxPython/src/msw/printfw.cpp index 439051fe69..97fe82d6f5 100644 --- a/wxPython/src/msw/printfw.cpp +++ b/wxPython/src/msw/printfw.cpp @@ -99,9 +99,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { // Since this one would be tough and ugly to do with the Macros... void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { bool hadErr = FALSE; + bool found; - bool doSave = wxPyRestoreThread(); - if (m_myInst.findCallback("GetPageInfo")) { + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = m_myInst.findCallback("GetPageInfo"))) { PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()")); if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { PyObject* val; @@ -131,10 +132,9 @@ void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *p } Py_DECREF(result); } - else + wxPyEndBlockThreads(state); + if (! found) wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); - - wxPySaveThread(doSave); } void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { diff --git a/wxPython/src/msw/streams.cpp b/wxPython/src/msw/streams.cpp index b0a643c58d..9be56272d9 100644 --- a/wxPython/src/msw/streams.cpp +++ b/wxPython/src/msw/streams.cpp @@ -279,7 +279,7 @@ protected: if (bufsize == 0) return 0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arglist = Py_BuildValue("(i)", bufsize); PyObject* result = PyEval_CallObject(read, arglist); Py_DECREF(arglist); @@ -297,7 +297,7 @@ protected: } else m_lasterror = wxSTREAM_READ_ERROR; - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); m_lastcount = o; return o; } @@ -308,17 +308,17 @@ protected: } virtual off_t OnSysSeek(off_t off, wxSeekMode mode){ - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject*arglist = Py_BuildValue("(ii)", off, mode); PyObject*result = PyEval_CallObject(seek, arglist); Py_DECREF(arglist); Py_XDECREF(result); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return OnSysTell(); } virtual off_t OnSysTell() const{ - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arglist = Py_BuildValue("()"); PyObject* result = PyEval_CallObject(tell, arglist); Py_DECREF(arglist); @@ -327,7 +327,7 @@ protected: o = PyInt_AsLong(result); Py_DECREF(result); }; - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return o; } @@ -337,12 +337,12 @@ protected: public: ~wxPyCBInputStream() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_XDECREF(py); Py_XDECREF(read); Py_XDECREF(seek); Py_XDECREF(tell); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } virtual size_t GetSize() { diff --git a/wxPython/src/msw/windows.cpp b/wxPython/src/msw/windows.cpp index 52c1bd4987..b1e106ce9e 100644 --- a/wxPython/src/msw/windows.cpp +++ b/wxPython/src/msw/windows.cpp @@ -103,11 +103,11 @@ public: ~wxPyValidator() { } - wxObject* wxPyValidator::Clone() const { + wxObject* Clone() const { wxPyValidator* ptr = NULL; wxPyValidator* self = (wxPyValidator*)this; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (self->m_myInst.findCallback("Clone")) { PyObject* ro; ro = self->m_myInst.callCallbackObj(Py_BuildValue("()")); @@ -116,13 +116,13 @@ public: Py_DECREF(ro); } } + wxPyEndBlockThreads(state); + // This is very dangerous!!! But is the only way I could find // to squash a memory leak. Currently it is okay, but if the // validator architecture in wxWindows ever changes, problems // could arise. delete self; - - wxPySaveThread(doSave); return ptr; } diff --git a/wxPython/src/msw/wx.cpp b/wxPython/src/msw/wx.cpp index 2f83d89d75..61274261aa 100644 --- a/wxPython/src/msw/wx.cpp +++ b/wxPython/src/msw/wx.cpp @@ -643,8 +643,9 @@ static wxPyCoreAPI API = { SWIG_addvarlink, SWIG_newvarlink, - wxPySaveThread, - wxPyRestoreThread, + wxPyBeginBlockThreads, + wxPyEndBlockThreads, + wxPyConstructObject, wxPy_ConvertList, diff --git a/wxPython/src/printfw.i b/wxPython/src/printfw.i index d1cb54d6eb..4ab596d72e 100644 --- a/wxPython/src/printfw.i +++ b/wxPython/src/printfw.i @@ -219,9 +219,10 @@ public: // Since this one would be tough and ugly to do with the Macros... void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { bool hadErr = FALSE; + bool found; - bool doSave = wxPyRestoreThread(); - if (m_myInst.findCallback("GetPageInfo")) { + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = m_myInst.findCallback("GetPageInfo"))) { PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()")); if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { PyObject* val; @@ -251,10 +252,9 @@ void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *p } Py_DECREF(result); } - else + wxPyEndBlockThreads(state); + if (! found) wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); - - wxPySaveThread(doSave); } void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { diff --git a/wxPython/src/streams.i b/wxPython/src/streams.i index 57daa51833..4426a09a2d 100644 --- a/wxPython/src/streams.i +++ b/wxPython/src/streams.i @@ -246,7 +246,7 @@ protected: if (bufsize == 0) return 0; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arglist = Py_BuildValue("(i)", bufsize); PyObject* result = PyEval_CallObject(read, arglist); Py_DECREF(arglist); @@ -264,7 +264,7 @@ protected: } else m_lasterror = wxSTREAM_READ_ERROR; - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); m_lastcount = o; return o; } @@ -275,17 +275,17 @@ protected: } virtual off_t OnSysSeek(off_t off, wxSeekMode mode){ - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject*arglist = Py_BuildValue("(ii)", off, mode); PyObject*result = PyEval_CallObject(seek, arglist); Py_DECREF(arglist); Py_XDECREF(result); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return OnSysTell(); } virtual off_t OnSysTell() const{ - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyObject* arglist = Py_BuildValue("()"); PyObject* result = PyEval_CallObject(tell, arglist); Py_DECREF(arglist); @@ -294,7 +294,7 @@ protected: o = PyInt_AsLong(result); Py_DECREF(result); }; - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); return o; } @@ -304,12 +304,12 @@ protected: public: ~wxPyCBInputStream() { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); Py_XDECREF(py); Py_XDECREF(read); Py_XDECREF(seek); Py_XDECREF(tell); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } virtual size_t GetSize() { diff --git a/wxPython/src/windows.i b/wxPython/src/windows.i index c12a316811..c75d8aeaab 100644 --- a/wxPython/src/windows.i +++ b/wxPython/src/windows.i @@ -104,11 +104,11 @@ public: ~wxPyValidator() { } - wxObject* wxPyValidator::Clone() const { + wxObject* Clone() const { wxPyValidator* ptr = NULL; wxPyValidator* self = (wxPyValidator*)this; - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); if (self->m_myInst.findCallback("Clone")) { PyObject* ro; ro = self->m_myInst.callCallbackObj(Py_BuildValue("()")); @@ -117,13 +117,13 @@ public: Py_DECREF(ro); } } + wxPyEndBlockThreads(state); + // This is very dangerous!!! But is the only way I could find // to squash a memory leak. Currently it is okay, but if the // validator architecture in wxWindows ever changes, problems // could arise. delete self; - - wxPySaveThread(doSave); return ptr; } diff --git a/wxPython/src/wx.i b/wxPython/src/wx.i index da1553eb92..c9d140bc72 100644 --- a/wxPython/src/wx.i +++ b/wxPython/src/wx.i @@ -161,8 +161,9 @@ static wxPyCoreAPI API = { SWIG_addvarlink, SWIG_newvarlink, - wxPySaveThread, - wxPyRestoreThread, + wxPyBeginBlockThreads, + wxPyEndBlockThreads, + wxPyConstructObject, wxPy_ConvertList, diff --git a/wxPython/wxPython/lib/colourselect.py b/wxPython/wxPython/lib/colourselect.py index c1140a6d71..590cf64e76 100644 --- a/wxPython/wxPython/lib/colourselect.py +++ b/wxPython/wxPython/lib/colourselect.py @@ -20,25 +20,26 @@ from wxPython.wx import * # call back to function if changes made class ColourSelect(wxButton): - def __init__(self, parent, position = wxPoint(20, 20), bcolour = [0, 0, 0], size = wxSize(20, 20), callback = None): + def __init__(self, parent, ID, bcolour=[0, 0, 0], pos=wxPoint(20, 20), size=wxSize(20, 20), style=0, callback=None): + wxButton.__init__(self, parent, ID, "", pos, size, style) self.win = parent self.callback = callback - - mID = NewId() - self.b = b = wxButton(parent, mID, "", position, size) - EVT_BUTTON(parent, mID, self.OnClick) - + EVT_BUTTON(self, ID, self.OnClick) self.SetColourValue(bcolour) + def __del__(self): + if hasattr(self, "set_colour_val"): + del self.set_colour_val + def SetColour(self, bcolour): - self.b.SetBackgroundColour(bcolour) + self.SetBackgroundColour(bcolour) def SetColourValue(self, bcolour): - self.set_colour_val = wxColor(bcolour[0], bcolour[1], bcolour[2]) + self.set_colour_val = wxColour(bcolour[0], bcolour[1], bcolour[2]) self.set_colour = bcolour - self.b.SetBackgroundColour(self.set_colour_val) - self.b.SetForegroundColour(wxWHITE) + self.SetBackgroundColour(self.set_colour_val) + self.SetForegroundColour(wxWHITE) def SetValue(self, bcolour): self.SetColourValue(bcolour) @@ -59,7 +60,7 @@ class ColourSelect(wxButton): data = dlg.GetColourData() self.set_colour = set = data.GetColour().Get() self.set_colour_val = bcolour = wxColour(set[0],set[1],set[2]) - self.b.SetBackgroundColour(bcolour) + self.SetBackgroundColour(bcolour) self.OnChange() dlg.Destroy() diff --git a/wxPython/wxPython/lib/printout.py b/wxPython/wxPython/lib/printout.py index bca1aee4a4..944da991b6 100644 --- a/wxPython/wxPython/lib/printout.py +++ b/wxPython/wxPython/lib/printout.py @@ -612,12 +612,11 @@ class PrintTable: def SetPreviewSize(self, position = wxPoint(0, 0), size="Full"): if size == "Full": - screenWidth = int(wx.wxSystemSettings_GetSystemMetric(wx.wxSYS_SCREEN_X)) - screenHeight = int(wx.wxSystemSettings_GetSystemMetric(wx.wxSYS_SCREEN_Y)) - self.preview_frame_size = wxSize(screenWidth, screenHeight) - self.preview_frame_pos = position + r = wxGetClientDisplayRect() + self.preview_frame_size = wxSize(r.width, r.height) + self.preview_frame_pos = wxPoint(r.x, r.y) else: - self.preview_frame_size = size + self.preview_frame_size = size self.preview_frame_pos = position def SetPaperId(self, paper): -- 2.45.2