X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3c7fc996a73e9f6a83067bc28a3c5581a3fee65..7198c3368055d88249a338eb33b21f051f674806:/src/mgl/app.cpp diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 53c61fad16..753d2df7f6 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -32,6 +32,7 @@ #include "wx/univ/colschem.h" #include "wx/sysopt.h" #include "wx/mgl/private.h" +#include "wx/private/fontmgr.h" //----------------------------------------------------------------------------- // wxApp::Exit() @@ -43,54 +44,6 @@ void wxApp::Exit() exit(0); } -//----------------------------------------------------------------------------- -// wxYield -//----------------------------------------------------------------------------- - -static bool gs_inYield = false; - -bool wxApp::Yield(bool onlyIfNeeded) -{ - if ( gs_inYield ) - { - if ( !onlyIfNeeded ) - { - wxFAIL_MSG( wxT("wxYield called recursively" ) ); - } - - return false; - } - -#if wxUSE_THREADS - if ( !wxThread::IsMain() ) - { - // can't process events from other threads, MGL is thread-unsafe - return true; - } -#endif // wxUSE_THREADS - - gs_inYield = true; - - wxLog::Suspend(); - - if ( wxEventLoop::GetActive() ) - { - while (wxEventLoop::GetActive()->Pending()) - wxEventLoop::GetActive()->Dispatch(); - } - - /* it's necessary to call ProcessIdle() to update the frames sizes which - might have been changed (it also will update other things set from - OnUpdateUI() which is a nice (and desired) side effect) */ - while (wxTheApp->ProcessIdle()) { } - - wxLog::Resume(); - - gs_inYield = false; - - return true; -} - //----------------------------------------------------------------------------- // wxWakeUpIdle @@ -167,8 +120,7 @@ static bool wxCreateMGL_WM(const wxVideoMode& displayMode) g_displayDC = new MGLDisplayDC(mode, 1, refresh); if ( !g_displayDC->isValid() ) { - delete g_displayDC; - g_displayDC = NULL; + wxDELETE(g_displayDC); return false; } @@ -186,11 +138,7 @@ static void wxDestroyMGL_WM() MGL_wmDestroy(g_winMng); g_winMng = NULL; } - if ( g_displayDC ) - { - delete g_displayDC; - g_displayDC = NULL; - } + wxDELETE(g_displayDC); } //----------------------------------------------------------------------------- @@ -199,11 +147,6 @@ static void wxDestroyMGL_WM() IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler) -BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) - EVT_IDLE(wxAppBase::OnIdle) -END_EVENT_TABLE() - - wxApp::wxApp() { } @@ -218,7 +161,7 @@ wxVideoMode wxGetDefaultDisplayMode() unsigned w, h, bpp; if ( !wxGetEnv(wxT("WXMODE"), &mode) || - (wxSscanf(mode.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3) ) + (wxSscanf(mode.c_str(), wxT("%ux%u-%u"), &w, &h, &bpp) != 3) ) { w = 640, h = 480, bpp = 16; } @@ -254,13 +197,12 @@ bool wxApp::OnInitGui() if ( !wxAppBase::OnInitGui() ) return false; -#ifdef __WXDEBUG__ - // MGL redirects stdout and stderr to physical console, so lets redirect - // it to file in debug build. Do it only when WXSTDERR environment variable is set + // MGL redirects stdout and stderr to physical console, so let's redirect + // it to file if WXSTDERR environment variable is set to be able to see + // wxLogDebug() output wxString redirect; if ( wxGetEnv(wxT("WXSTDERR"), &redirect) ) freopen(redirect.mb_str(), "wt", stderr); -#endif // __WXDEBUG__ wxLog *oldLog = wxLog::SetActiveTarget(new wxLogGui); if ( oldLog ) delete oldLog; @@ -283,14 +225,8 @@ bool wxApp::Initialize(int& argc, wxChar **argv) return false; } - // must do it before calling wxAppBase::Initialize(), because fonts are - // needed by stock lists which are created there - wxTheFontsManager = new wxFontsManager; - if ( !wxAppBase::Initialize(argc, argv) ) { - delete wxTheFontsManager; - wxTheFontsManager = NULL; MGL_exit(); return false; } @@ -313,8 +249,7 @@ struct wxMGLFinalCleanup: public wxModule void OnExit() { - delete wxTheFontsManager; - wxTheFontsManager = (wxFontsManager*) NULL; + wxFontsManager::CleanUp(); wxDestroyMGL_WM(); MGL_exit();