I am using 5th edition sdk to see if our application would work on it. Initially it was written for 3rd MR edition. I managed to crash 5th edition emulator when my code uses gradient brush. (by the way – our code works fine on 3rd edition)
I have a label control which has a custom background drawer. Here is the function which performs the gradient brush drawing.
EXPORT_C void CGradientBackground::Draw(
const CCoeControl& /*aControl*/,
const TRect& aRect) const
TInt brushWidth = aRect.Height();
brushWidth = aRect.Width();
//Create gradient brush
CFbsBitmap* pBrush = THEMECLASS::CreateGradientBrush(
//Draw the brush bitmap
} // end if(iTop==iBottom)
The function itself executes with no problem but when after it finishes the emulator crashes with the following error:
148.750 BitGdi internal Panic EBitgdiPanicInvalidBitmap, in file RECT.CPP @ line 360
148.750 Assert condition = "brushbitmap != NULL"
148.750 Thread wserv.exe::Wserv Panic BITGDI 13
148.750 FAULT: KERN 0x00000004 (4)
It looks to me that line aGc.DiscardBrushPattern(); does not reset internal brushbitmap pointer. I tried adding aGc.SetBrushStyle(CGraphicsContext::ENullBrush); before discarding the brush and after (before deleting the brush) but it does not make any difference. Is it a bug or I am missing something and how can I solve it? As I said the error only comes up on 5th edition emulator.