From 52e424485f1ce3e190e654bfad23ef74160b5535 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Wed, 1 Jul 2009 04:55:53 +0000 Subject: [PATCH] Do not BootGame if there are no items in the GameListCtrl, fix test to see if cancel was chosen from File > Open. Fixes issue 1046. it does leak 10kB every time that GetSelectedISO is called, I am not too worried about this. The other ways of accomplishing this would be more complicated, for little gain. Feel free to revert everything except line 466 of FrameTools.cpp :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3625 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 4 ++-- Source/Core/DolphinWX/Src/FrameTools.cpp | 7 ++++--- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 9a00225ab5..25c4d6d47d 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -508,8 +508,8 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event)) // 2. All Regions are set to hide // Otherwise call BootGame to either... // 1. Boot the selected iso - // 2. Call BrowseForDirectory and boot the default or last loaded iso. - // TODO: (LPFaint99) We shouldn't boot an iso after BrowseForDirectory + // 2. Boot the default or last loaded iso. + // 3. Call BrowseForDirectory if the gamelist is empty if (!m_GameListCtrl->GetGameNames().size() && !((SConfig::GetInstance().m_ListGC || SConfig::GetInstance().m_ListWii || diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index e24282bb58..a3e63928a1 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -420,8 +420,9 @@ void CFrame::BootGame() } UpdateGUI(); } - // Start the selected ISO - else if (m_GameListCtrl->GetSelectedISO() != 0) + // Start the selected ISO, return if gamelist is empty + else if (m_GameListCtrl->GetSelectedISO() == 0) return; + else if (m_GameListCtrl->GetSelectedISO()->IsValid()) { BootManager::BootCore(m_GameListCtrl->GetSelectedISO()->GetFileName()); } @@ -462,7 +463,7 @@ void CFrame::DoOpen(bool Boot) wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST, this); - bool fileChosen = path ? true : false; + bool fileChosen = !path.IsEmpty(); std::string currentDir2 = File::GetCurrentDirectory(); diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 2766a23c4b..ffbfdfe678 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -727,8 +727,8 @@ const GameListItem * CGameListCtrl::GetSelectedISO() else { long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (item == -1) // -1 means the selection is bogus, not a gamelistitem - return 0; + if (item == wxNOT_FOUND) + return new GameListItem(""); else { // Here is a little workaround for multiselections: