All the Window and GDI (pen, bitmap, etc.) classes and also many

toplevel functions will now check that a wx.App object has already
been created and will raise a wx.PyNoAppError exception if not.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27565 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-06-01 21:38:05 +00:00
parent 68da5113e3
commit ab1f7d2aa9
79 changed files with 433 additions and 30 deletions

View 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...