Symbian
Symbian OS Library

FAQ-0959 Why does the DataAddress() of my CFbsBitmap appear invalid?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Graphics
Created: 01/09/2004 Modified: 01/14/2004
Number: FAQ-0959
Platform: Not Applicable

Question:
When attempting to access a bitmap directly the address returned by DataAddress() may become invalid over the progress of a program's execution. This FAQ explains why this address cannot be relied upon except in very specific circumstances.

Answer:
Bitmaps over 4KB are kept on a defragmented heap.

If a bitmap is deleted then all the bitmaps above it in the heap are moved down to fill the gap. The heap can be locked with calls to LockHeap() and UnlockHeap(), and DataAddress() is only valid in between these calls. When using DataAddress() outside of these calls the heap will be changing dynamically and thus any address copied from DataAddress() may quickly become invalid.

Care must be taken not to inadvertently leave the heap locked (there is a LockHeapLC for avoiding leaves doing this) or you will hang the whole machine and have to reset it! Also, it shouldn't be left locked for too long or it will stall the window server.