]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
SWIGged updates for wxGTK
[wxWidgets.git] / wxPython / src / helpers.cpp
index a1be4c16115f982097ff7e8a05486bd5f8da2ed4..bc9dab80718d2c307b2521ef10f7ace055eb31e8 100644 (file)
@@ -10,7 +10,6 @@
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#include <stdio.h>  // get the correct definition of NULL
 
 #undef DEBUG
 #include <Python.h>
@@ -29,7 +28,6 @@
 #include <wx/gtk/win_gtk.h>
 #endif
 
-
 //----------------------------------------------------------------------
 
 #if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE
@@ -80,8 +78,11 @@ BOOL WINAPI DllMain(
     LPVOID      lpvReserved  // reserved
    )
 {
-    wxSetInstance(hinstDLL);
-    return 1;
+    // If wxPython is embedded in another wxWindows app then
+    // the inatance has already been set.
+    if (! wxGetInstance())
+        wxSetInstance(hinstDLL);
+    return TRUE;
 }
 #endif
 
@@ -91,11 +92,10 @@ BOOL WINAPI DllMain(
 
 
 wxPyApp::wxPyApp() {
-//    printf("**** ctor\n");
+    SetUseBestVisual(TRUE);
 }
 
 wxPyApp::~wxPyApp() {
-//    printf("**** dtor\n");
 }
 
 
@@ -179,12 +179,14 @@ void __wxPreStart()
     wxPyTMutex = new wxMutex;
 #endif
 
-    // Bail out if there is already windows created.  This means that the
+    wxApp::CheckBuildOptions(wxBuildOptions());
+
+    // Bail out if there is already a wxApp created.  This means that the
     // toolkit has already been initialized, as in embedding wxPython in
-    // a C++ wxWindows app.
-    if (wxTopLevelWindows.Number() > 0)
+    // a C++ wxWindows app, so we don't need to call wxEntryStart.
+    if (wxTheApp != NULL) {
         return;
-
+    }
     wxPyDoCleanup = TRUE;
 
     int argc = 0;
@@ -223,13 +225,6 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
     if (!PyArg_ParseTuple(args, "O", &onInitFunc))
         return NULL;
 
-#if 0  // Try it out without this check, see how it does...
-    if (wxTopLevelWindows.Number() > 0) {
-        PyErr_SetString(PyExc_TypeError, "Only 1 wxApp per process!");
-        return NULL;
-    }
-#endif
-
     // This is the next part of the wxEntry functionality...
     int argc = 0;
     wxChar** argv = NULL;
@@ -527,8 +522,6 @@ PyObject* wxPyConstructObject(void* ptr,
 PyObject* wxPyConstructObject(void* ptr,
                               const wxString& className,
                               int setThisOwn) {
-    PyObject* obj;
-
     if (!ptr) {
         Py_INCREF(Py_None);
         return Py_None;
@@ -640,8 +633,9 @@ void wxPyBeginBlockThreads() {
 
 void wxPyEndBlockThreads() {
 #ifdef WXP_WITH_THREAD
-    PyThreadState* tstate = PyEval_SaveThread();
     // Is there any need to save it again?
+    // PyThreadState* tstate =
+    PyEval_SaveThread();
 #endif
 }