protect from reentry

This commit is contained in:
David Rose 2009-09-09 01:30:21 +00:00
parent ab5f99fb20
commit b71e4e1a35
3 changed files with 25 additions and 0 deletions

View File

@ -209,6 +209,25 @@ unregister_window_class() {
}
}
////////////////////////////////////////////////////////////////////
// Function: P3DWinSplashWindow::button_click_detected
// Access: Protected, Virtual
// Description: Called when a button click by the user is detected in
// set_mouse_data(), this method simply turns around and
// notifies the instance. It's a virtual method to give
// subclasses a chance to redirect this message to the
// main thread or process, as necessary.
////////////////////////////////////////////////////////////////////
void P3DWinSplashWindow::
button_click_detected() {
// Since this message is detected in the sub-thread in the Windows
// case, we have to protect ourselves from re-entry by grabbing the
// global _api_lock.
ACQUIRE_LOCK(_api_lock);
P3DSplashWindow::button_click_detected();
RELEASE_LOCK(_api_lock);
}
////////////////////////////////////////////////////////////////////
// Function: P3DWinSplashWindow::start_thread
// Access: Private

View File

@ -43,6 +43,9 @@ public:
static void register_window_class();
static void unregister_window_class();
protected:
virtual void button_click_detected();
private:
void start_thread();
void stop_thread();

View File

@ -42,6 +42,9 @@ using namespace std;
extern ostream *nout_stream;
#define nout (*nout_stream)
// Appears in p3d_plugin.cxx.
extern LOCK _api_lock;
// A convenience function for formatting a generic P3D_object to an
// ostream.
inline ostream &