×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Exclamation [moved] S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    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(
    CWindowGc& aGc,
    const CCoeControl& /*aControl*/,
    const TRect& aRect) const
    {
    aGc.SetPenStyle(CGraphicsContext::ENullPen);
    if(iTop==iBottom)
    {
    //Normal fill
    aGc.SetBrushColor(iTop);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    aGc.DrawRect(aRect);
    } else
    {
    TInt brushWidth = aRect.Height();
    if(iOrientation==ColorUtils::EBitmapOrientationHorizontal)
    brushWidth = aRect.Width();
    //Create gradient brush
    CFbsBitmap* pBrush = THEMECLASS::CreateGradientBrush(
    iOrientation, brushWidth,iTop,iBottom);
    if(pBrush)
    {
    aGc.UseBrushPattern(pBrush);
    aGc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
    aGc.SetBrushOrigin(TPoint(0,0));

    //Draw the brush bitmap
    aGc.DrawRect(aRect);

    aGc.DiscardBrushPattern();
    delete pBrush;
    }

    } // end if(iTop==iBottom)
    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
    }

    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.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    Neither "THEMECLASS" nor CreateGradientBrush seems to be familiar from any public S60 SDK-s. If they happen to be your own code, consider checking and fixing. If they happen to be part of some partnered API, make sure that you have also partnered it for S60 5th edition, since such kind of API-s can change without notification.

  3. #3
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    No the function CreateGradientBitmap is my own one (and resides in my own dll) and defined as follows:
    #define THEMECLASS themes::DeluxeTheme

    EXPORT_C CFbsBitmap* DeluxeTheme::CreateGradientBrush(
    ColorUtils::TBitmapOrientation aOrientation,
    TInt aWidth, const TRgb& aTop, const TRgb& aBottom)
    {
    RWsSession* Session=NULL;
    if(!iWsSession || !aWidth || !(Session = iWsSession->WsSession()) )
    return NULL;

    CFbsBitmap* brush = new CFbsBitmap();
    if(brush)
    {
    //Generate gradient brush bitmap
    ColorUtils::CreateGradientBitmapL(
    *brush, *Session, aWidth,
    aOrientation, aTop, aBottom);
    }
    return brush;
    }

    The result of iWsSession->WsSession() function call is a pointer to RWsSession* object which is initialised with my own dll initialisation (right at the begining when the application starts). I do use my gradient bitmap function alot but I first apply it to a bitmap in memory and then bitblip bitmap to the screen. In this case I am trying to use gradient brush direcly with WindowGs and it causes problems.

    As I said all this code works fine under S60 3rd MR, but throws up in S60 5th ed running in emulator. Thanks in advance.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    Uh.
    Re-check the first message:
    148.750 Assert condition = "brushbitmap != NULL"
    Only failed asserts get logged. So you brush is NULL. And indeed yes, there is a chance for returning NULL in your method.
    Use the debugger.

  5. #5
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    The brush is not NULL. After creating it I check it with the following code
    if(pBrush)
    {
    aGc.UseBrushPattern(pBrush);
    aGc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
    aGc.SetBrushOrigin(TPoint(0,0));

    //Draw the brush bitmap
    aGc.DrawRect(aRect);

    aGc.DiscardBrushPattern();
    delete pBrush;
    }
    which executes fine. Also before my function finises I set it to aGc.SetBrushStyle(CGraphicsContext::ENullBrush); since I have already used it to draw rectangle,discarded it and I do not need anymore.

  6. #6
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    Well - anyone any ideas? Shall I submitted it as a bug then?
    Last edited by palringosymbian; 2009-02-11 at 16:44.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    Yes, you should. Something is wrong with EPatternedBrush.
    Actually the bitmap is valid, since it can be displayed (this can be your workaround in the meantime: simply BitBlt your pattern with a loop - this can work in this specific case of drawing a rectangle).
    The other thing ("The function itself executes with no problem") is true because the Window Server works asynchronously, and it works in bursts - for conserving resources, several drawing instructions are collected on the client side, then they are transferred for execution in a single step. That is why you can really trace your method successfully in the debugger. But the execution of DrawRect is what actually dies - if you comment it, the code works.

  8. #8
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    61

    Re: S60 SDK5th edition and gradient bitmaps cause Panic BITGDI 13.

    Thanks wizard_hu_ for the reply. I'll try to log the bug. At the moment instead of gradient fill I just do a normal fill untill the bug is solved. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •