Bug-fix for Delphi 3.0 graphics.pas |
Adapted from description on The Delphi Bug List.
Two procedures in graphics.pas
are missing a call to BitmapCanvasList.UnlockList
.
This bug will cause VCL graphics functions, which have not
been called from the main thread, to hang. They cannot lock
BitmapCanvasList
because the main thread never unlocks it.
The only solution is to modify the two procedures in graphics.pas
as indicated below.
procedure FreeMemoryContexts Add the lines marked with red. |
||
procedure FreeMemoryContexts; var I: Integer; begin with BitmapCanvasList.LockList do begin try for I := Count-1 downto 0 do with TBitmapCanvas(Items[I]) do if TryLock then try FreeContext; finally Unlock; end; finally BitmapCanvasList.UnLockList; end; end; end; |
procedure DeselectBitmap Add the lines marked with red. |
||
procedure DeselectBitmap(AHandle: HBITMAP); var I: Integer; begin if AHandle = 0 then Exit; with BitmapCanvasList.LockList do try for I := Count - 1 downto 0 do with TBitmapCanvas(Items[I]) do if (FBitmap <> nil) and (FBitmap.FImage.FHandle = AHandle) then FreeContext; finally BitmapCanvasList.UnLockList; end; end; |