Allow wxPyCheckForApp to not raise an exception if one isn't wanted

This commit is contained in:
Robin Dunn
2017-06-08 12:05:30 -07:00
parent 99cc9ccadf
commit c655fd5f5a
2 changed files with 6 additions and 5 deletions

View File

@@ -160,7 +160,7 @@ struct wxPyAPI {
bool (*p_wxPyWrappedPtr_TypeCheck)(PyObject* obj, const wxString& className);
wxVariant (*p_wxVariant_in_helper)(PyObject* obj);
PyObject* (*p_wxVariant_out_helper)(const wxVariant& value);
bool (*p_wxPyCheckForApp)();
bool (*p_wxPyCheckForApp)(bool raiseException);
PyObject* (*p_wxPyMakeBuffer)(void* ptr, Py_ssize_t len, bool readOnly);
bool (*p_wxPyNumberSequenceCheck)(PyObject* obj, int reqLength);
void* (*p_wxPyGetCppPtr)(sipSimpleWrapper* sipPyObj);
@@ -245,8 +245,8 @@ inline PyObject* wxVariant_out_helper(const wxVariant& value)
// Check if a wx.App object has been created
inline bool wxPyCheckForApp()
{ return wxPyGetAPIPtr()->p_wxPyCheckForApp(); }
inline bool wxPyCheckForApp(bool raiseException=true)
{ return wxPyGetAPIPtr()->p_wxPyCheckForApp(raiseException); }
// Create a buffer object from a pointer and size

View File

@@ -431,11 +431,12 @@ PyObject* i_wxVariant_out_helper(const wxVariant& value)
// (Initialized in wxPyCoreModuleInject)
PyObject* wxPyNoAppError = NULL;
bool i_wxPyCheckForApp() {
bool i_wxPyCheckForApp(bool raiseException) {
if (wxTheApp != NULL)
return true;
else {
PyErr_SetString(wxPyNoAppError, "The wx.App object must be created first!");
if (raiseException)
PyErr_SetString(wxPyNoAppError, "The wx.App object must be created first!");
return false;
}
}