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
This commit is contained in:
Soren Jorvang 2010-07-07 22:00:41 +00:00
parent 0ad71eda6b
commit 0a47e12b18
3 changed files with 37 additions and 18 deletions

View File

@ -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();

View File

@ -48,10 +48,16 @@
IMPLEMENT_APP(DolphinApp)
BEGIN_EVENT_TABLE(DolphinApp, wxApp)
EVT_TIMER(wxID_ANY, DolphinApp::AfterInit)
END_EVENT_TABLE()
#include <wx/stdpaths.h>
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()

View File

@ -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);