Use new wxAppTraits::SafeMessageBox() in wxSafeShowMessage()
This allows to show message boxes in ports other than wxMSW too by doing it only when it is safe, i.e. when the GUI is initialized, while still keeping the old code directly using the native MessageBox() function for MSW for maximal robustness.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "wx/window.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/confbase.h"
|
||||
#include "wx/utils.h"
|
||||
@@ -584,3 +585,21 @@ bool wxGUIAppTraitsBase::HasStderr()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __WIN32__
|
||||
|
||||
bool wxGUIAppTraitsBase::SafeMessageBox(const wxString& text,
|
||||
const wxString& title)
|
||||
{
|
||||
// The modules are initialized only after a successful call to
|
||||
// wxApp::Initialize() in wxEntryStart, so it can be used as a proxy for
|
||||
// GUI availability (note that the mere existence of wxTheApp is not enough
|
||||
// for this).
|
||||
if ( !wxModule::AreInitialized() )
|
||||
return false;
|
||||
|
||||
wxMessageBox(text, title, wxOK | wxICON_ERROR);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // !__WIN32__
|
||||
|
||||
Reference in New Issue
Block a user