git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28928
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// that should be present in the derived (Python) class.
void wxPyApp::_BootstrapApp()
{
// that should be present in the derived (Python) class.
void wxPyApp::_BootstrapApp()
{
+ static bool haveInitialized = false;
+ bool result, blocked;
PyObject* retval = NULL;
PyObject* pyint = NULL;
PyObject* retval = NULL;
PyObject* pyint = NULL;
-
- // Get any command-line args passed to this program from the sys module
- int argc = 0;
- char** argv = NULL;
- bool blocked = wxPyBeginBlockThreads();
- PyObject* sysargv = PySys_GetObject("argv");
- if (sysargv != NULL) {
- argc = PyList_Size(sysargv);
- argv = new char*[argc+1];
- int x;
- for(x=0; x<argc; x++) {
- PyObject *pyArg = PyList_GetItem(sysargv, x);
- argv[x] = PyString_AsString(pyArg);
+
+ // Only initialize wxWidgets once
+ if (! haveInitialized) {
+
+ // Get any command-line args passed to this program from the sys module
+ int argc = 0;
+ char** argv = NULL;
+ blocked = wxPyBeginBlockThreads();
+ PyObject* sysargv = PySys_GetObject("argv");
+ if (sysargv != NULL) {
+ argc = PyList_Size(sysargv);
+ argv = new char*[argc+1];
+ int x;
+ for(x=0; x<argc; x++) {
+ PyObject *pyArg = PyList_GetItem(sysargv, x);
+ argv[x] = PyString_AsString(pyArg);
+ }
+ argv[argc] = NULL;
- argv[argc] = NULL;
- }
- wxPyEndBlockThreads(blocked);
+ wxPyEndBlockThreads(blocked);
- // Initialize wxWidgets
- result = wxEntryStart(argc, argv);
- delete [] argv;
+ // Initialize wxWidgets
+ result = wxEntryStart(argc, argv);
+ delete [] argv;
- blocked = wxPyBeginBlockThreads();
- if (! result) {
- PyErr_SetString(PyExc_SystemError,
- "wxEntryStart failed, unable to initialize wxWidgets!"
+ blocked = wxPyBeginBlockThreads();
+ if (! result) {
+ PyErr_SetString(PyExc_SystemError,
+ "wxEntryStart failed, unable to initialize wxWidgets!"
- " (Is DISPLAY set properly?)"
+ " (Is DISPLAY set properly?)"
- // On wxGTK the locale will be changed to match the system settings, but
- // Python needs to have LC_NUMERIC set to "C" in order for the floating
- // point conversions and such to work right.
+ // On wxGTK the locale will be changed to match the system settings, but
+ // Python needs to have LC_NUMERIC set to "C" in order for the floating
+ // point conversions and such to work right.
- setlocale(LC_NUMERIC, "C");
+ setlocale(LC_NUMERIC, "C");
- // The stock objects were all NULL when they were loaded into
- // SWIG generated proxies, so re-init those now...
- wxPy_ReinitStockObjects(3);
+ // The stock objects were all NULL when they were loaded into
+ // SWIG generated proxies, so re-init those now...
+ wxPy_ReinitStockObjects(3);
+ wxPyEndBlockThreads(blocked);
+ haveInitialized = true;
+ }
+
// It's now ok to generate exceptions for assertion errors.
wxPythonApp->SetStartupComplete(True);
// Call the Python wxApp's OnInit function
// It's now ok to generate exceptions for assertion errors.
wxPythonApp->SetStartupComplete(True);
// Call the Python wxApp's OnInit function
+ blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "OnInit")) {
PyObject* method = m_myInst.GetLastFound();
if (wxPyCBH_findCallback(m_myInst, "OnInit")) {
PyObject* method = m_myInst.GetLastFound();