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
This commit is contained in:
Robin Dunn
2001-09-16 01:51:13 +00:00
parent 72fa862b04
commit 19a97bd6f9
41 changed files with 1706 additions and 1146 deletions
+1 -1
View File
@@ -1 +1 @@
ver = '2.3.2b2'
ver = '2.3.2b3'
+10 -10
View File
@@ -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; i<filenames.GetCount(); i++) {
PyObject* str = PyString_FromString(filenames[i].c_str());
@@ -592,7 +592,7 @@ bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y,
if (m_myInst.findCallback("OnDropFiles"))
rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list));
Py_DECREF(list);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return rval;
}
+15 -14
View File
@@ -696,7 +696,7 @@ public:
int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
int retval = 0;
PyObject* func = (PyObject*)funcPtr;
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
PyObject* args = Py_BuildValue("(ii)", item1, item2);
PyObject* result = PyEval_CallObject(func, args);
@@ -706,7 +706,7 @@ public:
Py_DECREF(result);
}
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return retval;
}
@@ -941,9 +941,9 @@ public:
}
~wxPyTreeItemData() {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
Py_DECREF(m_obj);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
}
PyObject* GetData() {
@@ -952,9 +952,9 @@ public:
}
void SetData(PyObject* obj) {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
Py_DECREF(m_obj);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
m_obj = obj;
Py_INCREF(obj);
}
@@ -1017,15 +1017,16 @@ public:
int OnCompareItems(const wxTreeItemId& item1,
const wxTreeItemId& item2) {
int rval = 0;
bool doSave = wxPyRestoreThread();
if (m_myInst.findCallback("OnCompareItems"))
bool found;
wxPyTState* state = wxPyBeginBlockThreads();
if ((found = m_myInst.findCallback("OnCompareItems")))
rval = m_myInst.callCallback(Py_BuildValue(
"(OO)",
wxPyConstructObject((void*)&item1, "wxTreeItemId"),
wxPyConstructObject((void*)&item2, "wxTreeItemId")));
else
wxPyEndBlockThreads(state);
if (! found)
rval = wxTreeCtrl::OnCompareItems(item1, item2);
wxPySaveThread(doSave);
return rval;
}
PYPRIVATE;
@@ -1139,7 +1140,7 @@ public:
//size_t GetSelections(wxArrayTreeItemIds& selection);
%addmethods {
PyObject* GetSelections() {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
PyObject* rval = PyList_New(0);
wxArrayTreeItemIds array;
size_t num, x;
@@ -1149,7 +1150,7 @@ public:
PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE);
PyList_Append(rval, item);
}
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return rval;
}
}
@@ -1234,10 +1235,10 @@ public:
PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) {
wxRect rect;
if (self->GetBoundingRect(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 {
+3 -2
View File
@@ -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))
+1
View File
@@ -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);
+362 -301
View File
File diff suppressed because it is too large Load Diff
+71 -40
View File
@@ -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;
}
// 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!)
//
// 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;
}
+364 -326
View File
File diff suppressed because it is too large Load Diff
+9 -8
View File
@@ -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);
+2 -2
View File
@@ -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);
+1
View File
@@ -659,6 +659,7 @@ public:
};
IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
%}
+10 -10
View File
@@ -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; i<filenames.GetCount(); i++) {
PyObject* str = PyString_FromString(filenames[i].c_str());
@@ -302,7 +302,7 @@ bool wxPyFileDropTarget::OnDropFiles(wxCoord x, wxCoord y,
if (m_myInst.findCallback("OnDropFiles"))
rval = m_myInst.callCallback(Py_BuildValue("(iiO)",x,y,list));
Py_DECREF(list);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return rval;
}
+15 -14
View File
@@ -133,7 +133,7 @@ IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
int retval = 0;
PyObject* func = (PyObject*)funcPtr;
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
PyObject* args = Py_BuildValue("(ii)", item1, item2);
PyObject* result = PyEval_CallObject(func, args);
@@ -143,7 +143,7 @@ IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
Py_DECREF(result);
}
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return retval;
}
@@ -158,9 +158,9 @@ public:
}
~wxPyTreeItemData() {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
Py_DECREF(m_obj);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
}
PyObject* GetData() {
@@ -169,9 +169,9 @@ public:
}
void SetData(PyObject* obj) {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
Py_DECREF(m_obj);
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
m_obj = obj;
Py_INCREF(obj);
}
@@ -204,15 +204,16 @@ public:
int OnCompareItems(const wxTreeItemId& item1,
const wxTreeItemId& item2) {
int rval = 0;
bool doSave = wxPyRestoreThread();
if (m_myInst.findCallback("OnCompareItems"))
bool found;
wxPyTState* state = wxPyBeginBlockThreads();
if ((found = m_myInst.findCallback("OnCompareItems")))
rval = m_myInst.callCallback(Py_BuildValue(
"(OO)",
wxPyConstructObject((void*)&item1, "wxTreeItemId"),
wxPyConstructObject((void*)&item2, "wxTreeItemId")));
else
wxPyEndBlockThreads(state);
if (! found)
rval = wxTreeCtrl::OnCompareItems(item1, item2);
wxPySaveThread(doSave);
return rval;
}
PYPRIVATE;
@@ -7959,7 +7960,7 @@ static PyObject *_wrap_wxTreeCtrl_GetItemParent(PyObject *self, PyObject *args,
}
static PyObject * wxPyTreeCtrl_GetSelections(wxPyTreeCtrl *self) {
bool doSave = wxPyRestoreThread();
wxPyTState* state = wxPyBeginBlockThreads();
PyObject* rval = PyList_New(0);
wxArrayTreeItemIds array;
size_t num, x;
@@ -7969,7 +7970,7 @@ static PyObject * wxPyTreeCtrl_GetSelections(wxPyTreeCtrl *self) {
PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE);
PyList_Append(rval, item);
}
wxPySaveThread(doSave);
wxPyEndBlockThreads(state);
return rval;
}
static PyObject *_wrap_wxTreeCtrl_GetSelections(PyObject *self, PyObject *args, PyObject *kwargs) {
@@ -9596,10 +9597,10 @@ static PyObject *_wrap_wxTreeCtrl_SetItemDropHighlight(PyObject *self, PyObject
static PyObject * wxPyTreeCtrl_GetBoundingRect(wxPyTreeCtrl *self,const wxTreeItemId & item,int textOnly) {
wxRect rect;
if (self->GetBoundingRect(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 {
+38
View File
@@ -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 },
+3
View File
@@ -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
+624 -301
View File
File diff suppressed because it is too large Load Diff
+70
View File
@@ -185,6 +185,48 @@ class wxGridCellBoolRenderer(wxGridCellBoolRendererPtr):
class wxGridCellDateTimeRendererPtr(wxGridCellStringRendererPtr):
def __init__(self,this):
self.this = this
self.thisown = 0
def __repr__(self):
return "<C wxGridCellDateTimeRenderer instance at %s>" % (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 "<C wxGridCellEnumRenderer instance at %s>" % (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 "<C wxGridCellAutoWrapStringRenderer instance at %s>" % (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 "<C wxGridCellEnumEditor instance at %s>" % (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 "<C wxGridCellAutoWrapStringEditor instance at %s>" % (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
+9 -8
View File
@@ -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);
+2 -2
View File
@@ -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);
+1
View File
@@ -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 {
+5 -5
View File
@@ -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) {
+8 -8
View File
@@ -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() {
+4 -4
View File
@@ -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;
}
+3 -2
View File
@@ -643,8 +643,9 @@ static wxPyCoreAPI API = {
SWIG_addvarlink,
SWIG_newvarlink,
wxPySaveThread,
wxPyRestoreThread,
wxPyBeginBlockThreads,
wxPyEndBlockThreads,
wxPyConstructObject,
wxPy_ConvertList,
+5 -5
View File
@@ -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) {
+8 -8
View File
@@ -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() {
+4 -4
View File
@@ -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;
}
+3 -2
View File
@@ -161,8 +161,9 @@ static wxPyCoreAPI API = {
SWIG_addvarlink,
SWIG_newvarlink,
wxPySaveThread,
wxPyRestoreThread,
wxPyBeginBlockThreads,
wxPyEndBlockThreads,
wxPyConstructObject,
wxPy_ConvertList,