]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/thread.cpp
Set wxPendingEvents to NULL after deleting it
[wxWidgets.git] / src / msw / thread.cpp
index 0f5886b86fa783a752989fe60518eba31907e48a..7c5a377d5e2b03eea56ac94e395c46d6161164ae 100644 (file)
@@ -32,6 +32,7 @@
 #if wxUSE_THREADS
 
 #include "wx/msw/private.h"
+#include "wx/msw/missing.h"
 
 #include "wx/module.h"
 #include "wx/thread.h"
@@ -132,7 +133,7 @@ static bool gs_waitingForThread = FALSE;
 
 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);
@@ -173,6 +174,8 @@ private:
     wxMutexError LockTimeout(DWORD milliseconds);
 
     HANDLE m_mutex;
+
+    DECLARE_NO_COPY_CLASS(wxMutexInternal)
 };
 
 // all mutexes are recursive under Win32 so we don't use mutexType
@@ -242,7 +245,7 @@ wxMutexError wxMutexInternal::Unlock()
 {
     if ( !::ReleaseMutex(m_mutex) )
     {
-        wxLogLastError(_("ReleaseMutex()"));
+        wxLogLastError(_T("ReleaseMutex()"));
 
         return wxMUTEX_MISC_ERROR;
     }
@@ -264,13 +267,24 @@ public:
     bool IsOk() const { return m_semaphore != NULL; }
 
     wxSemaError Wait() { return WaitTimeout(INFINITE); }
-    wxSemaError TryWait() { return WaitTimeout(0); }
+
+    wxSemaError TryWait()
+    {
+        wxSemaError rc = WaitTimeout(0);
+        if ( rc == wxSEMA_TIMEOUT )
+            rc = wxSEMA_BUSY;
+
+        return rc;
+    }
+
     wxSemaError WaitTimeout(unsigned long milliseconds);
 
     wxSemaError Post();
 
 private:
     HANDLE m_semaphore;
+
+    DECLARE_NO_COPY_CLASS(wxSemaphoreInternal)
 };
 
 wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount)
@@ -316,7 +330,7 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds)
            return wxSEMA_NO_ERROR;
 
         case WAIT_TIMEOUT:
-           return wxSEMA_BUSY;
+           return wxSEMA_TIMEOUT;
 
         default:
             wxLogLastError(_T("WaitForSingleObject(semaphore)"));
@@ -535,6 +549,8 @@ private:
     wxThreadState m_state;      // state, see wxThreadState enum
     unsigned int  m_priority;   // thread priority in "wx" units
     DWORD         m_tid;        // thread id
+
+    DECLARE_NO_COPY_CLASS(wxThreadInternal)
 };
 
 THREAD_RETVAL THREAD_CALLCONV wxThreadInternal::WinThreadStart(void *param)
@@ -985,7 +1001,7 @@ 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
-        DWORD result;
+        DWORD result = 0;       // suppress warnings from broken compilers
         do
         {
             if ( IsMain() )