From f777aca3a6ba20a11816eacb2620ed884883bc97 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Thu, 21 Apr 2011 22:02:09 +0000 Subject: [PATCH] minor correction to the tools menu, no longer uses uninitialized data when system menu is not installed git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7477 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/FrameTools.cpp | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index b489c7c4e6..ca60de90d6 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -206,11 +206,20 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_INSTALLWAD, _("Install WAD")); - int sysmenuVersion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetTitleVersion(); - char sysmenuRegion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetCountryChar(); + const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); + if (SysMenu_Loader.IsValid()) + { + int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); + char sysmenuRegion = SysMenu_Loader.GetCountryChar(); + + toolsMenu->Append(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); + } + else + { + toolsMenu->Append(IDM_LOAD_WII_MENU, _("Load Wii System Menu")); + toolsMenu->Enable(IDM_LOAD_WII_MENU, false); + } - toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); - toolsMenu->Enable(IDM_LOAD_WII_MENU, DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid()); toolsMenu->Append(IDM_FIFOPLAYER, _("Fifo Player")); @@ -1346,15 +1355,19 @@ void CFrame::OnLoadWiiMenu(wxCommandEvent& event) u64 titleID = CBoot::Install_WiiWAD(path.mb_str()); if (titleID == TITLEID_SYSMENU) { - const DiscIO::INANDContentLoader & _Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); - if (_Loader.IsValid()) + const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); + if (SysMenu_Loader.IsValid()) { - int sysmenuVersion = _Loader.GetTitleVersion(); - char sysmenuRegion = _Loader.GetCountryChar(); + int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); + char sysmenuRegion = SysMenu_Loader.GetCountryChar(); GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(); GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); } + else + { + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(false); + } } }