Several little fixes.

Fixed a segfault in linux when a cd/dvd drive is empty or invalid and "Boot from DVD" or "Show Drives" are selected.
On all platforms if a game fails to load show the game list again.
The other things here are essentially code cleanup and won't be noticeable by most users.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5204 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-03-17 01:54:40 +00:00
parent a7b03fd2cd
commit 721935c6ff
9 changed files with 54 additions and 39 deletions

View File

@ -56,6 +56,7 @@ DriveReader::DriveReader(const char *drive)
0, &dwNotUsed, NULL); 0, &dwNotUsed, NULL);
#endif #endif
#else #else
SectorReader::SetSectorSize(2048);
file_ = fopen(drive, "rb"); file_ = fopen(drive, "rb");
if (file_) if (file_)
{ {
@ -83,7 +84,8 @@ DriveReader::~DriveReader()
hDisc = INVALID_HANDLE_VALUE; hDisc = INVALID_HANDLE_VALUE;
} }
#else #else
fclose(file_); if (file_)
fclose(file_);
file_ = 0; file_ = 0;
#endif #endif
} }

View File

@ -470,6 +470,7 @@ bool game_loading = false;
// 3. Boot last selected game // 3. Boot last selected game
void CFrame::BootGame(const std::string& filename) void CFrame::BootGame(const std::string& filename)
{ {
bool success = false;
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
@ -479,23 +480,23 @@ void CFrame::BootGame(const std::string& filename)
// Start the selected ISO, or try one of the saved paths. // Start the selected ISO, or try one of the saved paths.
// If all that fails, ask to add a dir and don't boot // If all that fails, ask to add a dir and don't boot
if (!filename.empty()) if (!filename.empty())
BootManager::BootCore(filename); success = BootManager::BootCore(filename);
else if (m_GameListCtrl->GetSelectedISO() != NULL) else if (m_GameListCtrl->GetSelectedISO() != NULL)
{ {
if (m_GameListCtrl->GetSelectedISO()->IsValid()) if (m_GameListCtrl->GetSelectedISO()->IsValid())
BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName()); success = BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName());
} }
else if (!StartUp.m_strDefaultGCM.empty() else if (!StartUp.m_strDefaultGCM.empty()
&& wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8))) && wxFileExists(wxString(StartUp.m_strDefaultGCM.c_str(), wxConvUTF8)))
{ {
BootManager::BootCore(StartUp.m_strDefaultGCM); success = BootManager::BootCore(StartUp.m_strDefaultGCM);
} }
else else
{ {
if (!SConfig::GetInstance().m_LastFilename.empty() if (!SConfig::GetInstance().m_LastFilename.empty()
&& wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8))) && wxFileExists(wxString(SConfig::GetInstance().m_LastFilename.c_str(), wxConvUTF8)))
{ {
BootManager::BootCore(SConfig::GetInstance().m_LastFilename); success = BootManager::BootCore(SConfig::GetInstance().m_LastFilename);
} }
else else
{ {
@ -506,6 +507,12 @@ void CFrame::BootGame(const std::string& filename)
return; return;
} }
} }
if (!success)
{
game_loading = false;
m_GameListCtrl->Enable();
m_GameListCtrl->Show();
}
} }
// Open file to boot // Open file to boot
@ -546,13 +553,7 @@ void CFrame::DoOpen(bool Boot)
{ {
if (!fileChosen) if (!fileChosen)
return; return;
BootManager::BootCore(std::string(path.mb_str())); StartGame(std::string(path.mb_str()));
// Game has been started, hide the game list
if (m_GameListCtrl->IsShown())
{
m_GameListCtrl->Disable();
m_GameListCtrl->Hide();
}
} }
else else
{ {
@ -661,7 +662,7 @@ void CFrame::StartGame(const std::string& filename)
void CFrame::OnBootDrive(wxCommandEvent& event) void CFrame::OnBootDrive(wxCommandEvent& event)
{ {
BootManager::BootCore(drives[event.GetId()-IDM_DRIVE1].c_str()); StartGame(drives[event.GetId()-IDM_DRIVE1]);
} }

View File

@ -129,10 +129,6 @@ GCPadConfigDialog::GCPadConfigDialog(wxWindow *parent, wxWindowID id, const wxSt
#endif #endif
UpdateGUI(); UpdateGUI();
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(GCPadConfigDialog::OnKeyDown),
(wxObject*)0, this);
} }
GCPadConfigDialog::~GCPadConfigDialog() GCPadConfigDialog::~GCPadConfigDialog()
@ -245,10 +241,7 @@ void GCPadConfigDialog::OnKeyDown(wxKeyEvent& event)
SaveButtonMapping(ClickedButton->GetId(), XKey); SaveButtonMapping(ClickedButton->GetId(), XKey);
#endif #endif
} }
m_ButtonMappingTimer->Stop(); EndGetButtons();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
} }
} }
@ -262,6 +255,10 @@ void GCPadConfigDialog::OnButtonClick(wxCommandEvent& event)
if (m_ButtonMappingTimer->IsRunning()) return; if (m_ButtonMappingTimer->IsRunning()) return;
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(GCPadConfigDialog::OnKeyDown),
(wxObject*)0, this);
// Create the button object // Create the button object
ClickedButton = (wxButton *)event.GetEventObject(); ClickedButton = (wxButton *)event.GetEventObject();
// Save old label so we can revert back // Save old label so we can revert back

View File

@ -235,6 +235,7 @@ class GCPadConfigDialog : public wxDialog
void ToBlank(bool ToBlank, int Id); void ToBlank(bool ToBlank, int Id);
void DoGetButtons(int _GetId); void DoGetButtons(int _GetId);
void EndGetButtons();
void SetButtonText(int id, const wxString &str); void SetButtonText(int id, const wxString &str);
wxString GetButtonText(int id); wxString GetButtonText(int id);
}; };

View File

@ -208,10 +208,7 @@ void GCPadConfigDialog::DoGetButtons(int _GetId)
{ {
DEBUG_LOG(PAD, "Timer Stopped for Pad:%i _GetId:%i", GCMapping[m_Page].ID, _GetId); DEBUG_LOG(PAD, "Timer Stopped for Pad:%i _GetId:%i", GCMapping[m_Page].ID, _GetId);
m_ButtonMappingTimer->Stop(); EndGetButtons();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
} }
// If we got a bad button // If we got a bad button
@ -227,6 +224,17 @@ void GCPadConfigDialog::DoGetButtons(int _GetId)
} }
} }
void GCPadConfigDialog::EndGetButtons(void)
{
wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(GCPadConfigDialog::OnKeyDown),
(wxObject*)0, this);
m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
}
// Convert the 0x8000 range values to BoxW and BoxH for the plot // Convert the 0x8000 range values to BoxW and BoxH for the plot
void GCPadConfigDialog::Convert2Box(int &x) void GCPadConfigDialog::Convert2Box(int &x)
{ {

View File

@ -355,8 +355,8 @@ void Initialize(void *init)
} }
void DoState(unsigned char **ptr, int mode) { void DoState(unsigned char **ptr, int mode) {
#ifndef _WIN32 #if !defined(_WIN32) && !defined(__linux__)
// WHY is this here?? // WHY is this here?? If macs don't need this it should be removed.
OpenGL_MakeCurrent(); OpenGL_MakeCurrent();
#endif #endif
// Clear all caches that touch RAM // Clear all caches that touch RAM

View File

@ -222,10 +222,7 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
DEBUG_LOG(WIIMOTE, "Timer Stopped for Pad:%i _GetId:%i", DEBUG_LOG(WIIMOTE, "Timer Stopped for Pad:%i _GetId:%i",
WiiMoteEmu::WiiMapping[m_Page].ID, _GetId); WiiMoteEmu::WiiMapping[m_Page].ID, _GetId);
m_ButtonMappingTimer->Stop(); EndGetButtons();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
} }
// If we got a bad button // If we got a bad button
@ -241,6 +238,17 @@ void WiimotePadConfigDialog::DoGetButtons(int _GetId)
} }
} }
void WiimotePadConfigDialog::EndGetButtons(void)
{
wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown),
(wxObject*)0, this);
m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
}
// Convert the 0x8000 range values to BoxW and BoxH for the plot // Convert the 0x8000 range values to BoxW and BoxH for the plot
void WiimotePadConfigDialog::Convert2Box(int &x) void WiimotePadConfigDialog::Convert2Box(int &x)
{ {

View File

@ -135,10 +135,6 @@ WiimotePadConfigDialog::WiimotePadConfigDialog(wxWindow *parent, wxWindowID id,
m_Notebook->ChangeSelection(m_Page); m_Notebook->ChangeSelection(m_Page);
// Set control values // Set control values
UpdateGUI(); UpdateGUI();
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown),
(wxObject*)0, this);
} }
WiimotePadConfigDialog::~WiimotePadConfigDialog() WiimotePadConfigDialog::~WiimotePadConfigDialog()
@ -247,10 +243,7 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event)
SaveButtonMapping(ClickedButton->GetId(), XKey); SaveButtonMapping(ClickedButton->GetId(), XKey);
#endif #endif
} }
m_ButtonMappingTimer->Stop(); EndGetButtons();
GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0;
ClickedButton = NULL;
} }
} }
@ -264,6 +257,10 @@ void WiimotePadConfigDialog::OnButtonClick(wxCommandEvent& event)
if (m_ButtonMappingTimer->IsRunning()) return; if (m_ButtonMappingTimer->IsRunning()) return;
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(WiimotePadConfigDialog::OnKeyDown),
(wxObject*)0, this);
// Create the button object // Create the button object
ClickedButton = (wxButton *)event.GetEventObject(); ClickedButton = (wxButton *)event.GetEventObject();
// Save old label so we can revert back // Save old label so we can revert back

View File

@ -288,6 +288,7 @@ class WiimotePadConfigDialog : public wxDialog
wxString GetButtonText(int id); wxString GetButtonText(int id);
void DoGetButtons(int id); void DoGetButtons(int id);
void EndGetButtons();
void UpdatePadInfo(wxTimerEvent& WXUNUSED(event)); void UpdatePadInfo(wxTimerEvent& WXUNUSED(event));
void ToBlank(bool ToBlank, int Id); void ToBlank(bool ToBlank, int Id);
void DoChangeDeadZone(); void DoChangeDeadZone();