]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/thread.cpp
a better fix for notebook page not being refreshed after Delete()
[wxWidgets.git] / src / msw / thread.cpp
index b3bc923c6877110b8bc2c5f703ccc49afc0d1c97..d93d017704c2d27c7abe938b44eee16dd8d89bc1 100644 (file)
@@ -32,6 +32,7 @@
 #if wxUSE_THREADS
 
 #include "wx/msw/private.h"
 #if wxUSE_THREADS
 
 #include "wx/msw/private.h"
+#include "wx/msw/missing.h"
 
 #include "wx/module.h"
 #include "wx/thread.h"
 
 #include "wx/module.h"
 #include "wx/thread.h"
@@ -132,7 +133,7 @@ static bool gs_waitingForThread = FALSE;
 
 wxCriticalSection::wxCriticalSection()
 {
 
 wxCriticalSection::wxCriticalSection()
 {
-    wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(m_buffer),
+    wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(wxCritSectBuffer),
                            wxCriticalSectionBufferTooSmall );
 
     ::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);
                            wxCriticalSectionBufferTooSmall );
 
     ::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);
@@ -971,10 +972,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
         {
             // set flag for wxIsWaitingForThread()
             gs_waitingForThread = TRUE;
         {
             // set flag for wxIsWaitingForThread()
             gs_waitingForThread = TRUE;
-
-#if wxUSE_GUI
-            wxBeginBusyCursor();
-#endif // wxUSE_GUI
         }
 
         // ask the thread to terminate
         }
 
         // ask the thread to terminate
@@ -989,16 +986,27 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
         // we can't just wait for the thread to terminate because it might be
         // calling some GUI functions and so it will never terminate before we
         // process the Windows messages that result from these functions
         // we can't just wait for the thread to terminate because it might be
         // calling some GUI functions and so it will never terminate before we
         // process the Windows messages that result from these functions
-        DWORD result;
+        DWORD result = 0;       // suppress warnings from broken compilers
         do
         {
         do
         {
+            if ( IsMain() )
+            {
+                // give the thread we're waiting for chance to do the GUI call
+                // it might be in
+                if ( (gs_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
+                {
+                    wxMutexGuiLeave();
+                }
+            }
+
             result = ::MsgWaitForMultipleObjects
                      (
                        1,              // number of objects to wait for
                        &hThread,       // the objects
                        FALSE,          // don't wait for all objects
                        INFINITE,       // no timeout
             result = ::MsgWaitForMultipleObjects
                      (
                        1,              // number of objects to wait for
                        &hThread,       // the objects
                        FALSE,          // don't wait for all objects
                        INFINITE,       // no timeout
-                       QS_ALLEVENTS    // return as soon as there are any events
+                       QS_ALLINPUT |   // return as soon as there are any events
+                       QS_ALLPOSTMESSAGE
                      );
 
             switch ( result )
                      );
 
             switch ( result )
@@ -1022,17 +1030,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
 
                         return wxTHREAD_KILLED;
                     }
 
                         return wxTHREAD_KILLED;
                     }
-
-                    if ( IsMain() )
-                    {
-                        // give the thread we're waiting for chance to exit
-                        // from the GUI call it might have been in
-                        if ( (gs_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
-                        {
-                            wxMutexGuiLeave();
-                        }
-                    }
-
                     break;
 
                 default:
                     break;
 
                 default:
@@ -1053,10 +1050,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
         if ( IsMain() )
         {
             gs_waitingForThread = FALSE;
         if ( IsMain() )
         {
             gs_waitingForThread = FALSE;
-
-#if wxUSE_GUI
-            wxEndBusyCursor();
-#endif // wxUSE_GUI
         }
     }
 
         }
     }