mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
WiimoteReal: Fix race between shutdown and FindWiimotes
If FindWiimotes() took more time than the UI shutting down, the scanner would try connecting a Wiimote and sending an event to the UI code long after it has shut down, which causes a segfault. This fixes the race by ignoring any found Wiimotes during shutdown. Normally this would have never happened, but it is possible with hidapi since Wiimotes can be connected before Dolphin starts.
This commit is contained in:
@ -500,6 +500,8 @@ void WiimoteScanner::ThreadFunc()
|
||||
Wiimote* found_board = nullptr;
|
||||
backend->FindWiimotes(found_wiimotes, found_board);
|
||||
{
|
||||
if (!g_real_wiimotes_initialized)
|
||||
continue;
|
||||
std::lock_guard<std::mutex> lk(g_wiimotes_mutex);
|
||||
std::for_each(found_wiimotes.begin(), found_wiimotes.end(), TryToConnectWiimote);
|
||||
if (found_board)
|
||||
@ -657,6 +659,7 @@ void Stop()
|
||||
// called when the Dolphin app exits
|
||||
void Shutdown()
|
||||
{
|
||||
g_real_wiimotes_initialized = false;
|
||||
g_wiimote_scanner.StopThread();
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "WiimoteReal::Shutdown");
|
||||
|
Reference in New Issue
Block a user