QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
PhMakeTransBitmap corrupts the image |
Ref. No. |
QNX.000009493 |
Category(ies) |
Development |
Issue |
We are developing an application in PhAB. Our application has a button which will display one of two images on it. When we click on the button, the image toggles between the two images. We called PhMakeTransBitmap to make the background of the image transparent. In Photon 1.13, the image changed without any problems. In Photon 1.14, the image is distorted when it appears for a second time. Is this a known bug?
|
Solution |
PhMakeTransBitmap() sets the Ph_RELEASE_TRANSPARENCY_MASK flag in image->flags. This flag tells the label to free the transparency bitmap when the widget is destroyed or the image is changed. As a result, the next time you use this image, the pointer to the image points to memory that has been freed and might have been allocated and overwritten by an unrelated part of the application.
The workaround is to clear the Ph_RELEASE_TRANSPARENCY_MASK flag after the call to PhMakeTransBitmap(). If you want to release the image later, you will have to restore the flag before calling PhReleaseImage(). If you do not do this, you will have a memory leak.
|
|