From 0a47e12b18cf7309f3becb8a83790e90e56a732f Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Wed, 7 Jul 2010 22:00:41 +0000 Subject: [PATCH] Add back AfterInit which essentially does such actions that would normally (on a fresh install) be triggered by the user clicking on the GUI. This notably includes refreshing the game list. The progress dialog used in the course of updating the game list relies on wxWidgets being able to yield to its event handler which isn't started until after OnInit. In fact, we might want to consider just moving all the initialization currently triggered by OnInit into AfterInit so that we can rely on the event handler running there. This would mean that we don't have to worry about whether those code paths are triggered by a user click or run at init time. This will require some more testing, though. For now just move automatic booting along as this requires the game list initialization to be done. We also could instead choose to special-case cases like updating the game list and simply not use a progress dialog there if the event handler isn't running, but this approach is clearly cleaner. See thread at http://code.google.com/p/dolphin-emu/source/detail?r=5848 . git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5849 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 2 -- Source/Core/DolphinWX/Src/Main.cpp | 46 +++++++++++++++++++---------- Source/Core/DolphinWX/Src/Main.h | 7 +++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 792bfd2715..69d1ae6369 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -498,8 +498,6 @@ CFrame::CFrame(wxFrame* parent, m_bControlsCreated = true; UpdateGUI(); - if (m_GameListCtrl) m_GameListCtrl->Update(); - // If we are rerecording create the status bar now instead of later when a game starts #ifdef RERECORDING ModifyStatusBar(); diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 47db5b8b1b..7963be6806 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -48,10 +48,16 @@ IMPLEMENT_APP(DolphinApp) +BEGIN_EVENT_TABLE(DolphinApp, wxApp) + EVT_TIMER(wxID_ANY, DolphinApp::AfterInit) +END_EVENT_TABLE() + #include bool wxMsgAlert(const char*, const char*, bool, int); CFrame* main_frame = NULL; +static bool LoadFile = false; +static wxString FileToLoad; #ifdef WIN32 //Has no error handling. @@ -88,12 +94,10 @@ bool DolphinApp::OnInit() // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; - bool LoadFile = false; bool selectVideoPlugin = false; bool selectAudioPlugin = false; bool selectWiimotePlugin = false; - wxString FileToLoad; wxString videoPluginFilename; wxString audioPluginFilename; wxString wiimotePluginFilename; @@ -381,17 +385,37 @@ bool DolphinApp::OnInit() main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(title), wxPoint(x, y), wxSize(w, h), UseDebugger, UseLogger); + SetTopWindow(main_frame); - // ------------ - // Check the autoboot options. +#if defined HAVE_X11 && HAVE_X11 + XInitThreads(); +#endif + + // Postpone final actions until event handler is running + m_afterinit = new wxTimer(this, wxID_ANY); + m_afterinit->Start(1, wxTIMER_ONE_SHOT); + + return true; +} + +void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event)) +{ + delete m_afterinit; + + // Updating the game list makes use of wxProgressDialog which may + // only be run after OnInit() when the event handler is running. + main_frame->UpdateGameList(); + + // Check the autoboot options: // First check if we have an exec command line. if (LoadFile && FileToLoad != wxEmptyString) { main_frame->BootGame(std::string(FileToLoad.mb_str())); } - // If we have selected Automatic Start, start the default ISO, or if no default - // ISO exists, start the last loaded ISO + + // If we have selected Automatic Start, start the default ISO, + // or if no default ISO exists, start the last loaded ISO else if (main_frame->g_pCodeWindow) { if (main_frame->g_pCodeWindow->AutomaticStart()) @@ -410,16 +434,6 @@ bool DolphinApp::OnInit() } } } - // --------------------- - - // Set main parent window - SetTopWindow(main_frame); - -#if defined HAVE_X11 && HAVE_X11 - XInitThreads(); -#endif - - return true; } void DolphinApp::OnEndSession() diff --git a/Source/Core/DolphinWX/Src/Main.h b/Source/Core/DolphinWX/Src/Main.h index 207e2236f3..2d51c6a863 100644 --- a/Source/Core/DolphinWX/Src/Main.h +++ b/Source/Core/DolphinWX/Src/Main.h @@ -29,6 +29,13 @@ public: void OnEndSession(); int OnExit(); CFrame* GetCFrame(); + +private: + DECLARE_EVENT_TABLE() + + wxTimer *m_afterinit; + + void AfterInit(wxTimerEvent& WXUNUSED(event)); }; DECLARE_APP(DolphinApp);