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
This commit is contained in:
LPFaint99
2009-08-12 05:57:59 +00:00
parent 70f5d17d43
commit b4faea0186
2 changed files with 19 additions and 10 deletions

View File

@ -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,18 +316,22 @@ void ChangeDiscCallback(u64 userdata, int cyclesLate)
// Empty the drive
VolumeHandler::EjectVolume();
}
else if (VolumeHandler::SetVolumeName(FileName))
else
{
delete [] (char *) userdata;
if (VolumeHandler::SetVolumeName(FileName))
{
// Save the new ISO file name
SavedFileName = FileName;
}
else
{
PanicAlert("Invalid file");
PanicAlert("Invalid file \n %s", FileName.c_str());
// Put back the old one
VolumeHandler::SetVolumeName(SavedFileName);
}
}
SetLidOpen(false);
SetDiscInside(VolumeHandler::IsValid());

View File

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