mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Work around shutdown hang when compiling with SIMPLE_THREADS=1
This is a workaround for a specific case of #508
This commit is contained in:
parent
932e981572
commit
dc599901bc
@ -464,6 +464,23 @@ destroy_message_loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a signal to the thread input thread, asking it to shut itself down.
|
||||||
|
*/
|
||||||
|
void WinInputDeviceManager::
|
||||||
|
stop_thread() {
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
WinInputDeviceManager *mgr = (WinInputDeviceManager *)_global_ptr;
|
||||||
|
if (mgr != nullptr) {
|
||||||
|
LightMutexHolder holder(mgr->_lock);
|
||||||
|
HWND hwnd = mgr->_message_hwnd;
|
||||||
|
if (hwnd) {
|
||||||
|
PostMessage(hwnd, WM_QUIT, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the message loop.
|
* Implementation of the message loop.
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
HWND setup_message_loop();
|
HWND setup_message_loop();
|
||||||
void destroy_message_loop();
|
void destroy_message_loop();
|
||||||
|
|
||||||
|
static void stop_thread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// There are always exactly four of these in existence.
|
// There are always exactly four of these in existence.
|
||||||
XInputDevice _xinput_device0;
|
XInputDevice _xinput_device0;
|
||||||
|
@ -49,6 +49,10 @@
|
|||||||
#include "callbackGraphicsWindow.h"
|
#include "callbackGraphicsWindow.h"
|
||||||
#include "depthTestAttrib.h"
|
#include "depthTestAttrib.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
|
||||||
|
#include "winInputDeviceManager.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#define WINDOWS_LEAN_AND_MEAN
|
#define WINDOWS_LEAN_AND_MEAN
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
@ -637,6 +641,12 @@ remove_all_windows() {
|
|||||||
PStatClient::get_global_pstats()->disconnect();
|
PStatClient::get_global_pstats()->disconnect();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
|
||||||
|
// Send a message to the input message pump asking it to shut itself down.
|
||||||
|
// If we don't do that, the next call will deadlock.
|
||||||
|
WinInputDeviceManager::stop_thread();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Well, and why not clean up all threads here?
|
// Well, and why not clean up all threads here?
|
||||||
Thread::prepare_for_exit();
|
Thread::prepare_for_exit();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user