Forum > LCL

Is TResourceCacheItem thread-safe?

(1/1)

Bernd:
Hi,

I have the problem that I get exceptions in the class TResourceCacheItem at the line

  if FReferenceCount=0 then
    RaiseRefCountZero;       // <----------

in LCLResCache.pas (Method "TResourceCacheItem.DecreaseRefCount;"). The function "RaiseRefCountZero" is called (which throws the exception), because "FReferenceCount" is zero and some other routine wants to decrement the variable.

The stack trace shows that it is always called from the class "TFontHandleCache". I create images in different threads and write some text on them. The problem does not occurs in each iteration.

Do I have to block each bitmap operation (TBitmap from graphics.pp) with a critical section? Any hint is welcome.

Navigation

[0] Message Index

Go to full version