]> git.saurik.com Git - wxWidgets.git/commitdiff
Better handling of the refcount of the wx.App object, so it now
authorRobin Dunn <robin@alldunn.com>
Mon, 11 Apr 2005 19:14:34 +0000 (19:14 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 11 Apr 2005 19:14:34 +0000 (19:14 +0000)
destroyed when expected and also resets the current instance pointer
returned by wx.GetApp().

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

wxPython/src/_app.i
wxPython/src/_app_ex.py
wxPython/src/helpers.cpp

index 5628f0242b7aa4fe619e51c4c77a777c19c5425b..5aa20a5d5577a73e861de8b9d1e5fb7d7bf1c0cf 100644 (file)
@@ -48,8 +48,8 @@ class wxPyApp : public wxEvtHandler {
 public:
 
     %pythonAppend wxPyApp
 public:
 
     %pythonAppend wxPyApp
-       "self._setCallbackInfo(self, PyApp)
-        self._setOORInfo(self)";
+       "self._setCallbackInfo(self, PyApp, False)
+        self._setOORInfo(self, False)";
     %typemap(out) wxPyApp*;    // turn off this typemap
 
     DocStr(wxPyApp,
     %typemap(out) wxPyApp*;    // turn off this typemap
 
     DocStr(wxPyApp,
@@ -67,7 +67,7 @@ public:
     %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
 
 
     %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
 
 
-    void _setCallbackInfo(PyObject* self, PyObject* _class);
+    void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
 
 
     DocDeclStr(
 
 
     DocDeclStr(
index bae7df624e75cdf8622922e7b089a94804229945..98b35efc212a94eec07311750638d9c861e384f3 100644 (file)
@@ -176,9 +176,12 @@ your Mac."""
     def __del__(self):
         try:
             self.RestoreStdio()  # Just in case the MainLoop was overridden
     def __del__(self):
         try:
             self.RestoreStdio()  # Just in case the MainLoop was overridden
-        except:
-            pass
+        finally:
+            wx.PyApp.__del__(self)
 
 
+    def Destroy(self):
+        wx.PyApp.Destroy(self)
+        self.thisown = 0
 
     def SetTopWindow(self, frame):
         """Set the \"main\" top level window"""
 
     def SetTopWindow(self, frame):
         """Set the \"main\" top level window"""
index 1a23c8f8d671ad2b77894cc29b48abb2dc4073b2..f37f539ecad7deb469a1ac624571cc5f345e43b4 100644 (file)
@@ -126,6 +126,8 @@ wxPyApp::wxPyApp() {
 
 
 wxPyApp::~wxPyApp() {
 
 
 wxPyApp::~wxPyApp() {
+    wxPythonApp = NULL;
+    wxApp::SetInstance(NULL);
 }
 
 
 }
 
 
@@ -408,11 +410,11 @@ void wxPyApp::_BootstrapApp()
         if (sysargv != NULL && executable != NULL) {
             argc = PyList_Size(sysargv) + 1;
             argv = new char*[argc+1];
         if (sysargv != NULL && executable != NULL) {
             argc = PyList_Size(sysargv) + 1;
             argv = new char*[argc+1];
-            argv[0] = PyString_AsString(executable);
+            argv[0] = strdup(PyString_AsString(executable));
             int x;
             for(x=1; x<argc; x++) {
                 PyObject *pyArg = PyList_GetItem(sysargv, x-1);
             int x;
             for(x=1; x<argc; x++) {
                 PyObject *pyArg = PyList_GetItem(sysargv, x-1);
-                argv[x] = PyString_AsString(pyArg);
+                argv[x] = strdup(PyString_AsString(pyArg));
             }
             argv[argc] = NULL;
         }
             }
             argv[argc] = NULL;
         }
@@ -420,7 +422,7 @@ void wxPyApp::_BootstrapApp()
 
         // Initialize wxWidgets
         result = wxEntryStart(argc, argv);
 
         // Initialize wxWidgets
         result = wxEntryStart(argc, argv);
-        delete [] argv;
+        // wxApp takes ownership of the argv array, don't delete it here
 
         blocked = wxPyBeginBlockThreads();
         if (! result)  {
 
         blocked = wxPyBeginBlockThreads();
         if (! result)  {