Sometimes we do need to allow recursion of callbacks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -92,7 +92,8 @@ inline wxPyCoreAPI* wxPyGetCoreAPIPtr()
|
|||||||
#define wxColour_typecheck(a) (wxPyGetCoreAPIPtr()->p_wxColour_typecheck(a))
|
#define wxColour_typecheck(a) (wxPyGetCoreAPIPtr()->p_wxColour_typecheck(a))
|
||||||
|
|
||||||
#define wxPyCBH_setCallbackInfo(a, b, c, d) (wxPyGetCoreAPIPtr()->p_wxPyCBH_setCallbackInfo(a,b,c,d))
|
#define wxPyCBH_setCallbackInfo(a, b, c, d) (wxPyGetCoreAPIPtr()->p_wxPyCBH_setCallbackInfo(a,b,c,d))
|
||||||
#define wxPyCBH_findCallback(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_findCallback(a, b))
|
#define wxPyCBH_findCallback(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_findCallback(a, b, true))
|
||||||
|
#define wxPyCBH_findCallback2(a, b, c) (wxPyGetCoreAPIPtr()->p_wxPyCBH_findCallback(a, b, c))
|
||||||
#define wxPyCBH_callCallback(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_callCallback(a, b))
|
#define wxPyCBH_callCallback(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_callCallback(a, b))
|
||||||
#define wxPyCBH_callCallbackObj(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_callCallbackObj(a, b))
|
#define wxPyCBH_callCallbackObj(a, b) (wxPyGetCoreAPIPtr()->p_wxPyCBH_callCallbackObj(a, b))
|
||||||
#define wxPyCBH_delete(a) (wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(a))
|
#define wxPyCBH_delete(a) (wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(a))
|
||||||
|
@@ -405,7 +405,7 @@ struct wxPyCoreAPI {
|
|||||||
bool (*p_wxColour_typecheck)(PyObject* source);
|
bool (*p_wxColour_typecheck)(PyObject* source);
|
||||||
|
|
||||||
void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
|
void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
|
||||||
bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
|
bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name, bool setGuard);
|
||||||
int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
||||||
PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
||||||
void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
|
void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
|
||||||
@@ -560,7 +560,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setSelf(PyObject* self, PyObject* klass, int incref=true);
|
void setSelf(PyObject* self, PyObject* klass, int incref=true);
|
||||||
bool findCallback(const char* name) const;
|
bool findCallback(const char* name, bool setGuard=true) const;
|
||||||
int callCallback(PyObject* argTuple) const;
|
int callCallback(PyObject* argTuple) const;
|
||||||
PyObject* callCallbackObj(PyObject* argTuple) const;
|
PyObject* callCallbackObj(PyObject* argTuple) const;
|
||||||
PyObject* GetLastFound() const { return m_lastFound; }
|
PyObject* GetLastFound() const { return m_lastFound; }
|
||||||
@@ -579,7 +579,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
|
void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
|
||||||
bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
|
bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name, bool setGuard=true);
|
||||||
int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
||||||
PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
|
||||||
void wxPyCBH_delete(wxPyCallbackHelper* cbh);
|
void wxPyCBH_delete(wxPyCallbackHelper* cbh);
|
||||||
@@ -1432,7 +1432,7 @@ extern wxPyApp *wxPythonApp;
|
|||||||
bool CLASS::CBNAME(const wxHtmlTag& a) { \
|
bool CLASS::CBNAME(const wxHtmlTag& a) { \
|
||||||
bool rval=false; \
|
bool rval=false; \
|
||||||
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
|
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
|
||||||
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
|
if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
|
||||||
PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
|
PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
|
||||||
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
|
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
|
||||||
Py_DECREF(obj); \
|
Py_DECREF(obj); \
|
||||||
|
@@ -1775,7 +1775,7 @@ void wxPyCallbackHelper::clearRecursionGuard(PyObject* method) const
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
bool wxPyCallbackHelper::findCallback(const char* name) const {
|
bool wxPyCallbackHelper::findCallback(const char* name, bool setGuard) const {
|
||||||
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
|
wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
|
||||||
PyObject *method, *klass;
|
PyObject *method, *klass;
|
||||||
PyObject* nameo = PyString_FromString(name);
|
PyObject* nameo = PyString_FromString(name);
|
||||||
@@ -1795,6 +1795,7 @@ bool wxPyCallbackHelper::findCallback(const char* name) const {
|
|||||||
// ...then we'll save a pointer to the method so callCallback can
|
// ...then we'll save a pointer to the method so callCallback can
|
||||||
// call it. But first, set a recursion guard in case the
|
// call it. But first, set a recursion guard in case the
|
||||||
// overridden method wants to call the base class version.
|
// overridden method wants to call the base class version.
|
||||||
|
if (setGuard)
|
||||||
setRecursionGuard(method);
|
setRecursionGuard(method);
|
||||||
self->m_lastFound = method;
|
self->m_lastFound = method;
|
||||||
}
|
}
|
||||||
@@ -1847,8 +1848,8 @@ void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject*
|
|||||||
cbh.setSelf(self, klass, incref);
|
cbh.setSelf(self, klass, incref);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name) {
|
bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name, bool setGuard) {
|
||||||
return cbh.findCallback(name);
|
return cbh.findCallback(name, setGuard);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple) {
|
int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple) {
|
||||||
|
Reference in New Issue
Block a user