From b4faea0186f464a7c6e240647d2c98bcd5a597f2 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Wed, 12 Aug 2009 05:57:59 +0000 Subject: [PATCH] fix changedisc (broken by switch to unicode) char * was deallocated before callback was reached, How did it work before XTra.KrazzY? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3969 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/DVDInterface.cpp | 22 ++++++++++++++-------- Source/Core/DolphinWX/Src/FrameTools.cpp | 7 +++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index 6e78694354..5d2a1252e9 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -301,6 +301,8 @@ bool IsDiscInside() // Take care of all logic of "swapping discs" // We want this in the "backend", NOT the gui +// any !empty string will be deleted to ensure +// that the userdata string exists when called void ChangeDiscCallback(u64 userdata, int cyclesLate) { std::string FileName((const char*)userdata); @@ -314,17 +316,21 @@ void ChangeDiscCallback(u64 userdata, int cyclesLate) // Empty the drive VolumeHandler::EjectVolume(); } - else if (VolumeHandler::SetVolumeName(FileName)) - { - // Save the new ISO file name - SavedFileName = FileName; - } else { - PanicAlert("Invalid file"); + delete [] (char *) userdata; + if (VolumeHandler::SetVolumeName(FileName)) + { + // Save the new ISO file name + SavedFileName = FileName; + } + else + { + PanicAlert("Invalid file \n %s", FileName.c_str()); - // Put back the old one - VolumeHandler::SetVolumeName(SavedFileName); + // Put back the old one + VolumeHandler::SetVolumeName(SavedFileName); + } } SetLidOpen(false); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index ec2c74aeae..ea62484595 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -474,7 +474,10 @@ void CFrame::DoOpen(bool Boot) { if (!fileChosen) path = wxT(""); - DVDInterface::ChangeDisc((const char *)path.mb_str()); + // temp is deleted by changediscCallback + char * temp = new char[strlen(path.mb_str())]; + strncpy(temp, path.mb_str(), strlen(path.mb_str())); + DVDInterface::ChangeDisc(temp); } } @@ -631,7 +634,7 @@ void CFrame::OnShow_InfoWindow(wxCommandEvent& WXUNUSED (event)) void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED (event)) { - BootManager::BootCore(FULL_WII_MENU_DIR); + BootManager::BootCore(FULL_WII_MENU_DIR); } // Toogle fullscreen. In Windows the fullscreen mode is accomplished by expanding the m_Panel to cover