From: Robin Dunn <robin@alldunn.com>
Date: Fri, 5 Dec 2003 00:40:29 +0000 (+0000)
Subject: Fixed the double traceback when an exception happens in OnInit
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f048f8290f5388de598e0108aa5b4a01c68269d5

Fixed the double traceback when an exception happens in OnInit


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24714 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/wxPython/include/wx/wxPython/wxPython_int.h b/wxPython/include/wx/wxPython/wxPython_int.h
index 1487a714ab..af51069726 100644
--- a/wxPython/include/wx/wxPython/wxPython_int.h
+++ b/wxPython/include/wx/wxPython/wxPython_int.h
@@ -512,7 +512,8 @@ public:
     bool        findCallback(const char* name) const;
     int         callCallback(PyObject* argTuple) const;
     PyObject*   callCallbackObj(PyObject* argTuple) const;
-
+    PyObject*   GetLastFound() const { return m_lastFound; }
+    
 private:
     PyObject*   m_self;
     PyObject*   m_class;
diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp
index 24d16eb352..46012aa7ee 100644
--- a/wxPython/src/helpers.cpp
+++ b/wxPython/src/helpers.cpp
@@ -366,8 +366,16 @@ void wxPyApp::_BootstrapApp()
     
     // Call the Python wxApp's OnInit function
     if (wxPyCBH_findCallback(m_myInst, "OnInit")) {                
-        retval = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
-        pyint = PyNumber_Int(retval);
+
+        PyObject* method = m_myInst.GetLastFound();
+        PyObject* argTuple = PyTuple_New(0);
+        retval = PyEval_CallObject(method, argTuple);
+        Py_DECREF(argTuple);
+        Py_DECREF(method);
+        if (retval == NULL)
+            goto error;
+        
+        pyint = PyNumber_Int(retval);        
         if (! pyint) {
             PyErr_SetString(PyExc_TypeError, "OnInit should return a boolean value");
             goto error;
@@ -1447,7 +1455,7 @@ int wxPyCallbackHelper::callCallback(PyObject* argTuple) const {
 }
 
 // Invoke the Python callable object, returning the raw PyObject return
-// value.  Caller should DECREF the return value and also call PyEval_SaveThread.
+// value.  Caller should DECREF the return value and also manage the GIL.
 PyObject* wxPyCallbackHelper::callCallbackObj(PyObject* argTuple) const {
     PyObject* result;