If a wxPy[Command]Event has been cloned then we need to propogate the
Skip value from the original back to the clone after it has been processed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@22421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1225,29 +1225,50 @@ void wxPyCallback::EventThunker(wxEvent& event) {
|
|||||||
PyObject* result;
|
PyObject* result;
|
||||||
PyObject* arg;
|
PyObject* arg;
|
||||||
PyObject* tuple;
|
PyObject* tuple;
|
||||||
|
bool checkSkip = FALSE;
|
||||||
|
|
||||||
wxPyBeginBlockThreads();
|
wxPyBeginBlockThreads();
|
||||||
wxString className = event.GetClassInfo()->GetClassName();
|
wxString className = event.GetClassInfo()->GetClassName();
|
||||||
|
|
||||||
if (className == wxT("wxPyEvent"))
|
// If the event is one of these types then pass the original
|
||||||
arg = ((wxPyEvent*)&event)->GetSelf();
|
// event object instead of the one passed to us.
|
||||||
else if (className == wxT("wxPyCommandEvent"))
|
if ( className == wxT("wxPyEvent") ) {
|
||||||
arg = ((wxPyCommandEvent*)&event)->GetSelf();
|
arg = ((wxPyEvent*)&event)->GetSelf();
|
||||||
|
checkSkip = ((wxPyEvent*)&event)->GetCloned();
|
||||||
|
}
|
||||||
|
else if ( className == wxT("wxPyCommandEvent") ) {
|
||||||
|
arg = ((wxPyCommandEvent*)&event)->GetSelf();
|
||||||
|
checkSkip = ((wxPyCommandEvent*)&event)->GetCloned();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
arg = wxPyConstructObject((void*)&event, className);
|
arg = wxPyConstructObject((void*)&event, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call the event handler, passing the event object
|
||||||
tuple = PyTuple_New(1);
|
tuple = PyTuple_New(1);
|
||||||
PyTuple_SET_ITEM(tuple, 0, arg);
|
PyTuple_SET_ITEM(tuple, 0, arg); // steals ref to arg
|
||||||
result = PyEval_CallObject(func, tuple);
|
result = PyEval_CallObject(func, tuple);
|
||||||
Py_DECREF(tuple);
|
if ( result ) {
|
||||||
if (result) {
|
Py_DECREF(result); // result is ignored, but we still need to decref it
|
||||||
Py_DECREF(result);
|
|
||||||
PyErr_Clear(); // Just in case...
|
PyErr_Clear(); // Just in case...
|
||||||
} else {
|
} else {
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( checkSkip ) {
|
||||||
|
// if the event object was one of our special types and
|
||||||
|
// it had been cloned, then we need to extract the Skipped
|
||||||
|
// value from the original and set it in the clone.
|
||||||
|
result = PyObject_CallMethod(arg, "GetSkipped", "");
|
||||||
|
if ( result ) {
|
||||||
|
event.Skip(PyInt_AsLong(result));
|
||||||
|
Py_DECREF(result);
|
||||||
|
} else {
|
||||||
|
PyErr_Print();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF(tuple);
|
||||||
wxPyEndBlockThreads();
|
wxPyEndBlockThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -181,6 +181,7 @@ public:
|
|||||||
|
|
||||||
void SetSelf(PyObject* self, bool clone=FALSE);
|
void SetSelf(PyObject* self, bool clone=FALSE);
|
||||||
PyObject* GetSelf() const;
|
PyObject* GetSelf() const;
|
||||||
|
bool GetCloned() const { return m_cloned; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PyObject* m_self;
|
PyObject* m_self;
|
||||||
|
Reference in New Issue
Block a user