Changed (again) how the GIL is aquired and the tstate restored. This

time it's simpler, better, and handles the case where there is a wx
calback/event while the GIL has been released by a non-wxPython
extension module.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-03-24 23:09:59 +00:00
parent 70a4ef826f
commit da32eb53cb
31 changed files with 494 additions and 459 deletions

View File

@@ -238,7 +238,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) const {
// C++ version.
bool rval = False;
wxPyBeginBlockThreads();
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetDataHere")) {
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
@@ -249,7 +249,7 @@ bool wxPyDataObjectSimple::GetDataHere(void *buf) const {
Py_DECREF(ro);
}
}
wxPyEndBlockThreads();
wxPyEndBlockThreads(blocked);
return rval;
}
@@ -257,13 +257,13 @@ bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) const{
// For this one we simply need to make a string from buf and len
// and send it to the Python method.
bool rval = False;
wxPyBeginBlockThreads();
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetData")) {
PyObject* data = PyString_FromStringAndSize((char*)buf, len);
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", data));
Py_DECREF(data);
}
wxPyEndBlockThreads();
wxPyEndBlockThreads(blocked);
return rval;
}
%}
@@ -364,7 +364,7 @@ public:
wxBitmap wxPyBitmapDataObject::GetBitmap() const {
wxBitmap* rval = &wxNullBitmap;
wxPyBeginBlockThreads();
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetBitmap")) {
PyObject* ro;
wxBitmap* ptr;
@@ -375,18 +375,18 @@ wxBitmap wxPyBitmapDataObject::GetBitmap() const {
Py_DECREF(ro);
}
}
wxPyEndBlockThreads();
wxPyEndBlockThreads(blocked);
return *rval;
}
void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
wxPyBeginBlockThreads();
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) {
PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), False);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", bo));
Py_DECREF(bo);
}
wxPyEndBlockThreads();
wxPyEndBlockThreads(blocked);
}
%}