From 12b3fbbfd3d1bea36c7a4f1e5f91876ef4a64007 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 9 Aug 2004 07:24:19 +0000 Subject: [PATCH] catching errors git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/classic/thread.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/mac/classic/thread.cpp b/src/mac/classic/thread.cpp index 5e322a719d..ba4a0d012a 100644 --- a/src/mac/classic/thread.cpp +++ b/src/mac/classic/thread.cpp @@ -77,12 +77,18 @@ public : wxMacStCritical() { if ( UMASystemIsInitialized() ) - ThreadBeginCritical() ; + { + OSErr err = ThreadBeginCritical() ; + wxASSERT( err == noErr ) ; + } } ~wxMacStCritical() { if ( UMASystemIsInitialized() ) - ThreadEndCritical() ; + { + OSErr err = ThreadEndCritical() ; + wxASSERT( err == noErr ) ; + } } }; @@ -133,6 +139,7 @@ wxMutexError wxMutexInternal::Lock() m_waiters.Add(current); err = ::SetThreadStateEndCritical(kCurrentThreadID, kStoppedThreadState, m_owner); err = ::ThreadBeginCritical(); + wxASSERT( err == noErr ) ; } m_owner = current; } @@ -165,6 +172,7 @@ wxMutexError wxMutexInternal::Unlock() { OSErr err; err = ::ThreadBeginCritical(); + wxASSERT( err == noErr ) ; if (m_locked > 0) m_locked--; @@ -446,11 +454,13 @@ bool wxThreadInternal::Suspend() { OSErr err ; - ::ThreadBeginCritical(); + err = ::ThreadBeginCritical(); + wxASSERT( err == noErr ) ; if ( m_state != STATE_RUNNING ) { - ::ThreadEndCritical() ; + err = ::ThreadEndCritical() ; + wxASSERT( err == noErr ) ; wxLogSysError(_("Can not suspend thread %x"), m_tid); return FALSE; } @@ -471,19 +481,22 @@ bool wxThreadInternal::Resume() wxASSERT( err == noErr ) ; wxASSERT( current != m_tid ) ; - ::ThreadBeginCritical(); + err = ::ThreadBeginCritical(); + wxASSERT( err == noErr ) ; + if ( m_state != STATE_PAUSED && m_state != STATE_NEW ) { - ::ThreadEndCritical() ; + err = ::ThreadEndCritical() ; + wxASSERT( err == noErr ) ; wxLogSysError(_("Can not resume thread %x"), m_tid); return FALSE; } err = ::SetThreadStateEndCritical(m_tid, kReadyThreadState, kNoThreadID); - wxASSERT( err == noErr ) ; m_state = STATE_RUNNING; - ::ThreadEndCritical() ; + err = ::ThreadEndCritical() ; + wxASSERT( err == noErr ) ; ::YieldToAnyThread() ; return TRUE; }