From 84d1082a3bde3950f29e9e457411502444cde306 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 22 Oct 2008 00:42:55 +0200 Subject: [PATCH] Apply anotherguest's fixes. --- src/thread/symbian/SDL_syssem.cpp | 7 +++---- src/thread/symbian/SDL_systhread.cpp | 16 ++++++++++------ src/timer/symbian/SDL_systimer.cpp | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/thread/symbian/SDL_syssem.cpp b/src/thread/symbian/SDL_syssem.cpp index efefd6c..b74fde8 100644 --- a/src/thread/symbian/SDL_syssem.cpp +++ b/src/thread/symbian/SDL_syssem.cpp @@ -49,7 +49,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_SetError("Couldn't create semaphore"); } - SDL_semaphore* sem = new SDL_semaphore; + SDL_semaphore* sem = new SDL_semaphore; sem->handle = s.Handle(); sem->count = initial_value; return(sem); @@ -58,12 +58,11 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if ( sem ) + if ( sem ) { RSemaphore sema; sema.SetHandle(sem->handle); - while(--sem->count) - sema.Signal(); + sema.Signal(sem->count); sema.Close(); delete sem; sem = NULL; diff --git a/src/thread/symbian/SDL_systhread.cpp b/src/thread/symbian/SDL_systhread.cpp index d6e6f8b..de56d23 100644 --- a/src/thread/symbian/SDL_systhread.cpp +++ b/src/thread/symbian/SDL_systhread.cpp @@ -38,10 +38,13 @@ static int object_count; int RunThread(void* data) { CTrapCleanup* cleanup = CTrapCleanup::New(); + TRAPD(err, SDL_RunThread(data)); + EpocSdlEnv::CleanupItems(); delete cleanup; - return(err); + + return err; } int NewThread(const TDesC& aName, void* aPtr1, void* aPtr2) @@ -99,10 +102,9 @@ Uint32 SDL_ThreadID(void) void SDL_SYS_WaitThread(SDL_Thread *thread) { RThread t; - const int err = t.Open(thread->threadid); - if(err == KErrNone && t.ExitType() == EExitPending) + if(t.Open(thread->threadid) == KErrNone) { - TRequestStatus status; + TRequestStatus status = KRequestPending; t.Logon(status); User::WaitForRequest(status); } @@ -116,7 +118,9 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) void SDL_SYS_KillThread(SDL_Thread *thread) { RThread rthread; - rthread.SetHandle(thread->handle); - rthread.Kill(0); + if(rthread.Open(thread->threadid) == KErrNone) + { + rthread.Kill(0); + } rthread.Close(); } diff --git a/src/timer/symbian/SDL_systimer.cpp b/src/timer/symbian/SDL_systimer.cpp index 8272c3b..42cba01 100644 --- a/src/timer/symbian/SDL_systimer.cpp +++ b/src/timer/symbian/SDL_systimer.cpp @@ -44,7 +44,7 @@ extern "C" { Uint32 SDL_GetTicks(void) { const TUint32 deltaTics = User::NTickCount() - start; - return (deltaTics * tickPeriodMicroSeconds) / 1000; + return (deltaTics * tickPeriodMicroSeconds) / 1000; } void SDL_Delay(Uint32 ms) -- 2.11.4.GIT