Recent

Author Topic: [SOLVED] CheckSynchronize always returns false  (Read 427 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 391
[SOLVED] CheckSynchronize always returns false
« on: March 17, 2023, 12:40:05 pm »
rtl/objpas/classes/classes.inc has function CheckSynchronize(timeout : longint=0) : boolean;
I find it curious that the function always returns false.

Code: Pascal  [Select][+][-]
  1. function CheckSynchronize(timeout : longint=0) : boolean;
  2.  
  3. { assumes being called from GUI thread }
  4. var
  5.   ExceptObj: TObject;
  6.   tmpentry: TThread.PThreadQueueEntry;
  7.  
  8. begin
  9.   result:=false;
  10.   { first sanity check }
  11.   if Not IsMultiThread then
  12.     Exit
  13. {$ifdef FPC_HAS_FEATURE_THREADING}
  14.   { second sanity check }
  15.   else if GetCurrentThreadID<>MainThreadID then
  16.     raise EThread.CreateFmt(SCheckSynchronizeError,[GetCurrentThreadID]);
  17.   if timeout>0 then
  18.     RtlEventWaitFor(SynchronizeTimeoutEvent,timeout)
  19.   else
  20.     RtlEventResetEvent(SynchronizeTimeoutEvent);
  21.   tmpentry := PopThreadQueueHead;
  22.   while Assigned(tmpentry) do
  23.     begin
  24.     { step 2: execute the method }
  25.     exceptobj := Nil;
  26.     try
  27.       ExecuteThreadQueueEntry(tmpentry);
  28.     except
  29.       exceptobj := TObject(AcquireExceptionObject);
  30.     end;
  31.     { step 3: error handling and cleanup }
  32.     if Assigned(tmpentry^.SyncEvent) then
  33.       begin
  34.       { for Synchronize entries we pass back the Exception and trigger
  35.         the event that Synchronize waits in }
  36.       tmpentry^.Exception := exceptobj;
  37.       RtlEventSetEvent(tmpentry^.SyncEvent)
  38.       end
  39.     else
  40.       begin
  41.       { for Queue entries we dispose the entry and raise the exception }
  42.       Dispose(tmpentry);
  43.       if Assigned(exceptobj) then
  44.         raise exceptobj;
  45.       end;
  46.     tmpentry := PopThreadQueueHead;
  47.     end
  48. {$endif};
  49. end;
« Last Edit: March 18, 2023, 10:48:37 am by lagprogramming »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5283
  • Compiler Developer
Re: CheckSynchronize always returns false
« Reply #1 on: March 17, 2023, 03:55:42 pm »
I find it curious that the function always returns false.

Same. Fixed in e774a627

 

TinyPortal © 2005-2018