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,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);