Linux: Prevent infrequent freeze/crash when closing
This commit is contained in:
parent
7f7d7ab1b3
commit
36617a6055
3 changed files with 15 additions and 1 deletions
|
@ -242,6 +242,17 @@ namespace Mesen.GUI.Forms
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_shuttingDown && Program.IsMono) {
|
||||||
|
//This appears to prevent Mono from locking up when closing the form
|
||||||
|
Task.Run(() => {
|
||||||
|
StopEmu();
|
||||||
|
_shuttingDown = true;
|
||||||
|
this.BeginInvoke((Action)(() => this.Close()));
|
||||||
|
});
|
||||||
|
e.Cancel = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_shuttingDown = true;
|
_shuttingDown = true;
|
||||||
|
|
||||||
//Stop menu update timer, and process all pending events before stopping the core
|
//Stop menu update timer, and process all pending events before stopping the core
|
||||||
|
|
|
@ -270,6 +270,7 @@ LinuxKeyManager::LinuxKeyManager()
|
||||||
LinuxKeyManager::~LinuxKeyManager()
|
LinuxKeyManager::~LinuxKeyManager()
|
||||||
{
|
{
|
||||||
_stopUpdateDeviceThread = true;
|
_stopUpdateDeviceThread = true;
|
||||||
|
_stopSignal.Signal();
|
||||||
_updateDeviceThread.join();
|
_updateDeviceThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +388,7 @@ void LinuxKeyManager::StartUpdateDeviceThread()
|
||||||
Console::Resume();
|
Console::Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(2000));
|
_stopSignal.Wait(2000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "../Core/IKeyManager.h"
|
#include "../Core/IKeyManager.h"
|
||||||
|
#include "../Utilities/AutoResetEvent.h"
|
||||||
|
|
||||||
class LinuxGameController;
|
class LinuxGameController;
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ private:
|
||||||
|
|
||||||
std::thread _updateDeviceThread;
|
std::thread _updateDeviceThread;
|
||||||
atomic<bool> _stopUpdateDeviceThread;
|
atomic<bool> _stopUpdateDeviceThread;
|
||||||
|
AutoResetEvent _stopSignal;
|
||||||
bool _disableAllKeys;
|
bool _disableAllKeys;
|
||||||
|
|
||||||
void StartUpdateDeviceThread();
|
void StartUpdateDeviceThread();
|
||||||
|
|
Loading…
Add table
Reference in a new issue