From 285cc3abc02fea4aa47d43758a1341f44cd964d2 Mon Sep 17 00:00:00 2001 From: crs Date: Thu, 17 Oct 2002 21:37:41 +0000 Subject: [PATCH] Fixed CXWindowsScreen to force the event loop to wake up when exitMainLoop() is called. --- lib/platform/CXWindowsScreen.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/platform/CXWindowsScreen.cpp b/lib/platform/CXWindowsScreen.cpp index 5cf8fe80..2ebbbaf9 100644 --- a/lib/platform/CXWindowsScreen.cpp +++ b/lib/platform/CXWindowsScreen.cpp @@ -288,6 +288,7 @@ CXWindowsScreen::mainLoop() // if the thread has been cancelled. poll() should return -1 // with EINTR when the thread is cancelled. m_mutex.unlock(); + CThread::testCancel(); #if HAVE_POLL poll(pfds, 1, timeout); #else @@ -358,8 +359,28 @@ CXWindowsScreen::mainLoop() void CXWindowsScreen::exitMainLoop() { + // m_stop should be a condition variable that we signal here + // but we can't wait on both the condition variable and the + // X connection so there's no point. however, we do need + // to wake up the X connection so send ourself some event. CLock lock(&m_mutex); m_stop = true; + + if (m_display != NULL && m_window != None) { + XEvent event; + event.xclient.type = ClientMessage; + event.xclient.display = m_display; + event.xclient.window = m_window; + event.xclient.message_type = XInternAtom(m_display, "ATOM", False); + event.xclient.format = 32; + event.xclient.data.l[0] = 0; + event.xclient.data.l[1] = 0; + event.xclient.data.l[2] = 0; + event.xclient.data.l[3] = 0; + event.xclient.data.l[4] = 0; + CXWindowsUtil::CErrorLock lock(m_display); + XSendEvent(m_display, m_window, False, 0, &event); + } } void