From 4f1c322f1416a1b7984cf5f065e9a9a130ab3a05 Mon Sep 17 00:00:00 2001 From: dmitry Date: Tue, 21 Apr 2009 15:02:28 +0000 Subject: [PATCH] * removed fpc thread manager dependancy, otherwise single-threaded applications fail with runtime error git-svn-id: trunk@19558 - --- lcl/interfaces/carbon/carbonint.pas | 33 ++++++++++++++++++++++---- lcl/interfaces/carbon/carbonobject.inc | 4 ++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lcl/interfaces/carbon/carbonint.pas b/lcl/interfaces/carbon/carbonint.pas index 616ae22484..85087e995e 100644 --- a/lcl/interfaces/carbon/carbonint.pas +++ b/lcl/interfaces/carbon/carbonint.pas @@ -158,7 +158,27 @@ uses Spin, ExtCtrls, FileCtrl, LResources; var - FirstAppEventLock: pEventState = nil; + FirstAppEventLock: MPEventID = nil; + +const + EventFlags : MPEventFlags = 1; + +procedure SignalFirstAppEvent; +begin + MPSetEvent(FirstAppEventLock, EventFlags); +end; + +procedure WaitFirstAppEvent; +var + fl : MPEventFlags; +begin + fl := EventFlags; + if FirstAppEventLock <> nil then + begin + MPWaitForEvent(FirstAppEventLock, @fl, kDurationForever); + SignalFirstAppEvent; + end; +end; // the implementation of the utility methods {$I carbonobject.inc} @@ -170,14 +190,17 @@ var procedure InternalInit; begin - FirstAppEventLock:=BasicEventCreate(nil, true, false, ''); + MPCreateEvent(FirstAppEventLock); end; procedure InternalFinal; begin - basiceventSetEvent(FirstAppEventLock); - basiceventdestroy(FirstAppEventLock); - FirstAppEventLock:=nil; + if Assigned(FirstAppEventLock) then + begin + SignalFirstAppEvent; + MPDeleteEvent(FirstAppEventLock); + FirstAppEventLock:=nil; + end; end; diff --git a/lcl/interfaces/carbon/carbonobject.inc b/lcl/interfaces/carbon/carbonobject.inc index 194a7338eb..a898796427 100644 --- a/lcl/interfaces/carbon/carbonobject.inc +++ b/lcl/interfaces/carbon/carbonobject.inc @@ -431,7 +431,7 @@ begin then RaiseGDBException('TCarbonWidgetSet.AppRun post dummy event failed'); fMainEventQueue:=CurMainEventQueue; - basiceventSetEvent(FirstAppEventLock); + SignalFirstAppEvent; RunApplicationEventLoop; finally @@ -926,7 +926,7 @@ end; procedure TCarbonWidgetSet.OnWakeMainThread(Sender: TObject); begin // wait infinite for the first (dummy) event sent to the main event queue - basiceventWaitFor(-1, FirstAppEventLock); + WaitFirstAppEvent; SendCheckSynchronizeMessage; end;