X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dd116e73f0ad388e169676ec79cf176699956e7d..6946b604e8a01092aa68d1846a24c6350ea6df79:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 4c9f9beca8..57b971ae57 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -30,6 +30,7 @@ #include #include +#include //---------------------------------------------------------------------- @@ -383,7 +384,7 @@ void __wxPreStart(PyObject* moduleDict) #endif // Ensure that the build options in the DLL (or whatever) match this build - wxApp::CheckBuildOptions(wxBuildOptions()); + wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "wxPython"); // Create an exception object to use for wxASSERTions wxPyAssertionError = PyErr_NewException("wxPython.wxc.wxPyAssertionError", @@ -1305,29 +1306,50 @@ void wxPyCallback::EventThunker(wxEvent& event) { PyObject* result; PyObject* arg; PyObject* tuple; - + bool checkSkip = FALSE; wxPyBeginBlockThreads(); wxString className = event.GetClassInfo()->GetClassName(); - if (className == wxT("wxPyEvent")) - arg = ((wxPyEvent*)&event)->GetSelf(); - else if (className == wxT("wxPyCommandEvent")) - arg = ((wxPyCommandEvent*)&event)->GetSelf(); + // If the event is one of these types then pass the original + // event object instead of the one passed to us. + if ( className == wxT("wxPyEvent") ) { + arg = ((wxPyEvent*)&event)->GetSelf(); + checkSkip = ((wxPyEvent*)&event)->GetCloned(); + } + else if ( className == wxT("wxPyCommandEvent") ) { + arg = ((wxPyCommandEvent*)&event)->GetSelf(); + checkSkip = ((wxPyCommandEvent*)&event)->GetCloned(); + } else { arg = wxPyConstructObject((void*)&event, className); } + // Call the event handler, passing the event object 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); - Py_DECREF(tuple); - if (result) { - Py_DECREF(result); + if ( result ) { + Py_DECREF(result); // result is ignored, but we still need to decref it PyErr_Clear(); // Just in case... } else { 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(); } @@ -1563,8 +1585,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyEvent, wxEvent); IMPLEMENT_ABSTRACT_CLASS(wxPyCommandEvent, wxCommandEvent); -wxPyEvent::wxPyEvent(int id) - : wxEvent(id) { +wxPyEvent::wxPyEvent(int winid, wxEventType commandType) + : wxEvent(winid, commandType) { }