Panic due to CFbsBitmap loaded in Font and bitmap server

Login to reply to this topic.
Thu, 2005-02-17 09:25
Joined: 2005-02-17
Forum posts: 26
I am using the CImageEncoder class to encode a bitmap that I load like this;
----
_LIT(KTestMBM, "Z:\\system\\Apps\\T_ItFjmmSaveImageCat1\\T_ItFjmmSaveImage.MBM");
CFbsBitmap* bitty = new (ELeave) CFbsBitmap;
bitty->Load( KTestMBM, 0, EFalse);
----

The MBM file exists and there is no problem loading the bitmap. Later on when I use the CImageEncode below there is a Panic.
----
// Load the file
    TRAPD(err, iEncoder = CImageEncoder::FileNewL( iFs, aFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid ));
    if(err != KErrNone)
       {
       User::Leave(err);
       }
----

Now the reason for the Panic I understand. I am testing the application I made and am using an incorrect filename for the aFileName as the second parameter for the above FileNewL() API.

Now here is the problem that I would really appreciate help with. After the Leave in the above code the process returns to where I call FileNewL from. It is a test application and a snippet of its source was included at the top of this posting. Because of the Leave I try to release the memory that the CFbsBitmap reserves by the follwing;

bitty->Reset();
delete bitty;
bitty = NULL;

Despite this the font and bitmap server doesn't release the bitmap data and I get a Panic after the Leave. I understand that the CFbsBitmap pointer bitty is simply a handle to the data held by the font and bitmap server. I would like to know how to tell the bitmap server to release its memory since it is no longer needed. Or advice with maybe a solution where the test application and dll I am testing are in separate threads. Although I am getting out of my depth with that.

I appreciate any help you can give.

Niimidan


Thu, 2005-02-17 15:11
Joined: 2005-02-16
Forum posts: 22
Panic due to CFbsBitmap loaded in Font and bitmap server
_LIT(KTestMBM, "Z:\\system\\Apps\\T_ItFjmmSaveImageCat1\\T_ItFjmmSaveImage.MBM");
CFbsBitmap* bitty = new (ELeave) CFbsBitmap;
CleanupStack::PushL(bitty);
User::LeaveIfError(bitty->Load( KTestMBM, 0, EFalse));
iEncoder = CImageEncoder::FileNewL( iFs, aFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid ));
...
CleanupStack::PopAndDestroy(bitty); // or just Pop, if you want to keep it around
Fri, 2005-02-18 01:39
Joined: 2005-02-17
Forum posts: 26
Panic due to CFbsBitmap loaded in Font and bitmap server
Thanks for the reply Elk!

I tried the
TRAP(ret,  saveImage.SaveJpegL(KDestJPEGFileError, *this, info ) );
if(ret != KErrNone)
   {
   CleanupStack::PopAndDestroy( bitty ); // Elk's suggestion
   User::Leave( ret );   
   }
...

Even with that, the pesky Font and Bitmap server does not release that area of memory taken up at this point in the code.

User::LeaveIfError(bitty->Load( KTestMBM, 0, EFalse));

Once I load the bitmap from the MBM file, I can't seem to release the memory from the server.  

Is there something else I can try?

Thanks for the help.

Niimidan

Wed, 2005-03-09 09:43
Joined: 2005-02-17
Forum posts: 26
Still having trouble with CFbsBitmap
This problem is quite simple but I am missing something fundamental with how to allow the bitmap server to release the bitmap's associated memory. Even this little snippet of code will Panic.

__UHEAP_MARK;
_LIT(KTestMbm, "Z:\\SYSTEM\\APPS\\HelloWorld\\T_TestBitmap.MBM");
TInt id = 0;
CFbsBitmap* bitty = new (ELeave) CFbsBitmap();

bitty->Load(KTestMbm, 0, EFalse);
bitty->Reset();
delete bitty;
bitty = NULL;
__UHEAP_MARKEND;

At __UHEAP_MARK a Panic occurs. The bitmap itself is deleted but something is still not released from the server. Hmmm. Please help.

Niimidan

Tue, 2005-04-05 10:24
Joined: 2005-02-17
Forum posts: 26
Figured it out
Actually I took this question right to the top and asked Symbian support here in Japan.
Basically in my case, the deletion of the memory representing the CFbsBitmap object takes place asynchrously, as the CFbsBitmap was large, the cleanup actually took place after the session ended.
I ended up using a client / server architecture and checked the heap using __UHEAP_MARKEND; after the session was closed.

Niimidan

Tue, 2005-04-05 10:52
Joined: 2004-11-03
Forum posts: 26
Panic due to CFbsBitmap loaded in Font and bitmap server
Thanks for that info - it's definately something I will bear in mind when using CFbsBitmap.

S
  • Login to reply to this topic.