]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
test wxString's char<->wchar_t ctors
[wxWidgets.git] / wxPython / src / helpers.cpp
index c01fa664a407fae9102de5b82c41fd6c4d36b909..edb5a9179120fb161ad01dbdbba9c04fbf445327 100644 (file)
@@ -79,6 +79,7 @@ wxMutex*              wxPyTMutex = NULL;
 
 static PyObject* wxPython_dict = NULL;
 static PyObject* wxPyAssertionError = NULL;
+static PyObject* wxPyNoAppError = NULL;
 
 PyObject* wxPyPtrTypeMap = NULL;
 
@@ -567,7 +568,8 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
         return NULL;
 
     if (!PyDict_Check(wxPython_dict)) {
-        PyErr_SetString(PyExc_TypeError, "_wxPySetDictionary must have dictionary object!");
+        PyErr_SetString(PyExc_TypeError,
+                        "_wxPySetDictionary must have dictionary object!");
         return NULL;
     }
 
@@ -580,6 +582,12 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
                                             PyExc_AssertionError, NULL);
     PyDict_SetItemString(wxPython_dict, "PyAssertionError", wxPyAssertionError);
 
+    // Create an exception object to use when the app object hasn't been created yet
+    wxPyNoAppError = PyErr_NewException("wx._core.PyNoAppError",
+                                        PyExc_RuntimeError, NULL);
+    PyDict_SetItemString(wxPython_dict, "PyNoAppError", wxPyNoAppError);
+    
+
 
 #ifdef __WXMOTIF__
 #define wxPlatform "__WXMOTIF__"
@@ -636,7 +644,12 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
     _AddInfoString("gtk1");
 #endif
 #endif
-
+#ifdef __WXDEBUG__
+    _AddInfoString("wx-assertions-on");
+#else
+    _AddInfoString("wx-assertions-off");
+#endif
+    
 #undef _AddInfoString
 
     PyObject* PlatInfoTuple = PyList_AsTuple(PlatInfo);
@@ -823,6 +836,22 @@ void wxPy_ReinitStockObjects(int pass)
 
 //---------------------------------------------------------------------------
 
+// Check for existence of a wxApp, setting an exception if there isn't one.
+// This doesn't need to aquire the GIL because it should only be called from
+// an %exception before the lock is released.
+
+bool wxPyCheckForApp() {
+    if (wxTheApp != NULL)
+        return true;
+    else {
+        PyErr_SetString(wxPyNoAppError, "The wx.App object must be created first!");
+        return false;
+    }
+}
+
+//---------------------------------------------------------------------------
+
+
 void wxPyClientData_dtor(wxPyClientData* self) {
     if (! wxPyDoingCleanup) {           // Don't do it during cleanup as Python
                                         // may have already garbage collected the object...