Fixed a interpreter lock problem in the __eq__ and __ne__ methods in wxSize and etc.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,8 @@ unicode.
|
|||||||
Fixed problem where the wrong class name could sometimes be used for
|
Fixed problem where the wrong class name could sometimes be used for
|
||||||
OOR.
|
OOR.
|
||||||
|
|
||||||
|
Fixed a interpreter lock problem in the __eq__ and __ne__ methods in
|
||||||
|
wxSize and etc.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -368,22 +368,24 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxColour tmp;
|
wxColour tmp;
|
||||||
wxColour* ptr = &tmp;
|
wxColour* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxColour_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxColour tmp;
|
wxColour tmp;
|
||||||
wxColour* ptr = &tmp;
|
wxColour* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxColour_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "asTuple = Get
|
%pragma(python) addtoclass = "asTuple = Get
|
||||||
def __str__(self): return str(self.asTuple())
|
def __str__(self): return str(self.asTuple())
|
||||||
def __repr__(self): return 'wxColour: ' + str(self.asTuple())
|
def __repr__(self): return 'wxColour:' + str(self.asTuple())
|
||||||
def __nonzero__(self): return self.Ok()
|
def __nonzero__(self): return self.Ok()
|
||||||
def __getinitargs__(self): return ()
|
def __getinitargs__(self): return ()
|
||||||
def __getstate__(self): return self.asTuple()
|
def __getstate__(self): return self.asTuple()
|
||||||
|
@@ -2224,7 +2224,7 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
|
|||||||
*obj = ptr;
|
*obj = ptr;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
// otherwise a string is expected
|
// otherwise check for a string
|
||||||
else if (PyString_Check(source) || PyUnicode_Check(source)) {
|
else if (PyString_Check(source) || PyUnicode_Check(source)) {
|
||||||
wxString spec = Py2wxString(source);
|
wxString spec = Py2wxString(source);
|
||||||
if (spec.GetChar(0) == '#' && spec.Length() == 7) { // It's #RRGGBB
|
if (spec.GetChar(0) == '#' && spec.Length() == 7) { // It's #RRGGBB
|
||||||
@@ -2242,6 +2242,23 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// last chance: 3-tuple of integers is expected
|
||||||
|
else if (PySequence_Check(source) && PyObject_Length(source) == 3) {
|
||||||
|
PyObject* o1 = PySequence_GetItem(source, 0);
|
||||||
|
PyObject* o2 = PySequence_GetItem(source, 1);
|
||||||
|
PyObject* o3 = PySequence_GetItem(source, 2);
|
||||||
|
if (!PyNumber_Check(o1) || !PyNumber_Check(o2) || !PyNumber_Check(o3)) {
|
||||||
|
Py_DECREF(o1);
|
||||||
|
Py_DECREF(o2);
|
||||||
|
Py_DECREF(o3);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
**obj = wxColour(PyInt_AsLong(o1), PyInt_AsLong(o2), PyInt_AsLong(o3));
|
||||||
|
Py_DECREF(o1);
|
||||||
|
Py_DECREF(o2);
|
||||||
|
Py_DECREF(o3);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@@ -66,6 +66,8 @@ void wxPyEndAllowThreads(PyThreadState* state);
|
|||||||
void wxPyBeginBlockThreads();
|
void wxPyBeginBlockThreads();
|
||||||
void wxPyEndBlockThreads();
|
void wxPyEndBlockThreads();
|
||||||
|
|
||||||
|
#define wxPyBLOCK_THREADS(stmt) wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// These are helpers used by the typemaps
|
// These are helpers used by the typemaps
|
||||||
|
|
||||||
|
@@ -83,15 +83,17 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxSize tmp;
|
wxSize tmp;
|
||||||
wxSize* ptr = &tmp;
|
wxSize* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxSize_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxSize_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxSize tmp;
|
wxSize tmp;
|
||||||
wxSize* ptr = &tmp;
|
wxSize* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxSize_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxSize_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,17 +150,20 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxRealPoint tmp;
|
wxRealPoint tmp;
|
||||||
wxRealPoint* ptr = &tmp;
|
wxRealPoint* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxRealPoint_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxRealPoint_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxRealPoint tmp;
|
wxRealPoint tmp;
|
||||||
wxRealPoint* ptr = &tmp;
|
wxRealPoint* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxRealPoint_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxRealPoint_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
@@ -210,17 +215,20 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxPoint tmp;
|
wxPoint tmp;
|
||||||
wxPoint* ptr = &tmp;
|
wxPoint* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxPoint_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxPoint_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxPoint tmp;
|
wxPoint tmp;
|
||||||
wxPoint* ptr = &tmp;
|
wxPoint* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxPoint_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxPoint_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
@@ -308,17 +316,20 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxRect tmp;
|
wxRect tmp;
|
||||||
wxRect* ptr = &tmp;
|
wxRect* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxRect_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxRect_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxRect tmp;
|
wxRect tmp;
|
||||||
wxRect* ptr = &tmp;
|
wxRect* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxRect_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxRect_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
@@ -467,18 +478,21 @@ public:
|
|||||||
bool __eq__(PyObject* obj) {
|
bool __eq__(PyObject* obj) {
|
||||||
wxPoint2DDouble tmp;
|
wxPoint2DDouble tmp;
|
||||||
wxPoint2DDouble* ptr = &tmp;
|
wxPoint2DDouble* ptr = &tmp;
|
||||||
if (obj == Py_None) return FALSE;
|
if (obj == Py_None) return FALSE;
|
||||||
if (! wxPoint2DDouble_helper(obj, &ptr)) return FALSE;
|
wxPyBLOCK_THREADS(bool success = wxPoint2DDouble_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return FALSE;
|
||||||
return *self == *ptr;
|
return *self == *ptr;
|
||||||
}
|
}
|
||||||
bool __ne__(PyObject* obj) {
|
bool __ne__(PyObject* obj) {
|
||||||
wxPoint2DDouble tmp;
|
wxPoint2DDouble tmp;
|
||||||
wxPoint2DDouble* ptr = &tmp;
|
wxPoint2DDouble* ptr = &tmp;
|
||||||
if (obj == Py_None) return TRUE;
|
if (obj == Py_None) return TRUE;
|
||||||
if (! wxPoint2DDouble_helper(obj, &ptr)) return TRUE;
|
wxPyBLOCK_THREADS(bool success = wxPoint2DDouble_helper(obj, &ptr); PyErr_Clear());
|
||||||
|
if (! success) return TRUE;
|
||||||
return *self != *ptr;
|
return *self != *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject* asTuple() {
|
PyObject* asTuple() {
|
||||||
wxPyBeginBlockThreads();
|
wxPyBeginBlockThreads();
|
||||||
PyObject* tup = PyTuple_New(2);
|
PyObject* tup = PyTuple_New(2);
|
||||||
|
Reference in New Issue
Block a user