FDS: Fixed crash on power cycle

This commit is contained in:
Sour 2017-12-28 19:55:08 -05:00
parent 7137740cd2
commit 7f71773dd0
3 changed files with 19 additions and 14 deletions

View File

@ -53,27 +53,29 @@ public:
SetBit(FdsSystemActionManager::FdsButtons::InsertDisk1 + _insertDiskNumber);
}
}
}
void ProcessSystemActions() override
{
SystemActionManager::ProcessSystemActions();
bool needEject = IsPressed(FdsSystemActionManager::FdsButtons::EjectDiskButton);
int diskToInsert = -1;
for(int i = 0; i < 16; i++) {
if(IsPressed(FdsSystemActionManager::FdsButtons::InsertDisk1 + i)) {
diskToInsert = i;
break;
}
}
shared_ptr<FDS> mapper = _mapper.lock();
if(mapper) {
if(IsPressed(FdsSystemActionManager::FdsButtons::EjectDiskButton)) {
if(needEject || diskToInsert >= 0) {
shared_ptr<FDS> mapper = _mapper.lock();
if(needEject) {
mapper->EjectDisk();
}
for(int i = 0; i < 16; i++) {
if(IsPressed(FdsSystemActionManager::FdsButtons::InsertDisk1 + i)) {
mapper->InsertDisk(i);
break;
}
if(diskToInsert >= 0) {
mapper->InsertDisk(diskToInsert);
}
}
}
void EjectDisk()
{
_needEjectDisk = true;

View File

@ -61,7 +61,7 @@ public:
_needPowerCycle = true;
}
virtual void ProcessSystemActions()
void ProcessSystemActions()
{
shared_ptr<Console> console = _console.lock();
if(console) {
@ -70,6 +70,7 @@ public:
}
if(IsPressed(SystemActionManager::Buttons::PowerButton)) {
console->PowerCycle();
//Calling PowerCycle() causes this object to be deleted - no code must be written below this line
}
}
}

View File

@ -107,6 +107,8 @@ namespace Mesen.GUI.Config
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.TakeScreenshot, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("F12") }));
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadRandomGame, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("Insert") }));
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SwitchDiskSide, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("B") }));
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Reset, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("R") }));
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.PowerCycle, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("T") }));
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Pause, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Esc") }));