app crashes on orientation change
Hello guys,
I have this application which works fine in one orientation but when I change the orientation, it crashes and I don't know the reason also. Are there any specific reasons in this particular case?
In HandleResourceChange of my container, I am doing the following:
[CODE]
CCoeControl::HandleResourceChange(aType);
SetRect(iAvkonViewAppUi->View(TUid::Uid(ESomeViewId))->ClientRect());
CEikAppUi* appUi = CEikonEnv::Static()->EikAppUi();
CEikApplication* app = appUi->Application();
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
TFileName bitmapFile;
bitmapFile = (app->BitmapStoreName());
bitmapFile.SetLength(bitmapFile.LocateReverse('\\') + 1);
bitmapFile.Append(_L("Listbox_bitmaps.mif"));
CAknsItemDef* pMenuSkinItemCBA = AknsUtils::CreateBitmapItemDefL( KAknsIIDQsnBgAreaMain, bitmapFile,
EMbmListbox_bitmapsBackgroungcolor );
skin->SetLocalItemDefL( pMenuSkinItemCBA);
[/CODE]
If i just keep first two lines, the app does not crashes but it does not serve my purpose.
Any suggestions why its crashing?
Thanks
Re: app crashes on orientation change
A thing you may want to try is testing if the code can start up with changed orientation. If it can not, the problem is not about handling the change, but handling the orientation.
And of course it may be a good idea checking the panic code.
Re: app crashes on orientation change
Yes the code does work for me if I start the app in landscape orientation but again when i change that to portrait, it crashes and same thing if I start the app in portrait, it works fine but crashes on changing orientation to landscape. Can I get the panic code for release build because there are few libraries used by the app which are not available for emulator. So can't get it run on emulator. The problem occurs only on changing the orientation.
Re: app crashes on orientation change
[QUOTE=raj8nokiaforum;910728]Can I get the panic code for release build because there are few libraries used by the app which are not available for emulator. So can't get it run on emulator. [/QUOTE]
yep you can : [url]http://www.developer.nokia.com/Community/Wiki/Extended_panic_code[/url]
Re: app crashes on orientation change
Alright did that and found out that panic code is KERN-EXEC 0.
Moreover, I did some file logging and found out that problem is not in HandleResourceChange method. Actually there is a listbox that I display on top of this .svg background image. On changing the orientation, somehow iListbox becomes NULL and in sizeChanged method, iListbox is NULL. But the panic codes suggests some NULL resource handle isn't it?
Re: app crashes on orientation change
I am using RFs in my code but i don't know how handle to it is getting free because i am closing the RFs handle only in destructor. Any pointers?
Re: app crashes on orientation change
SetRect() invokes SizeChanged() which is the first statement in the HandleResourceChangeL().So you might want to put some more debug files after the SetRect() to see if code reaches till the end of HandleResourceChangeL() or not or/and put a log file at the end of SizeChanged() as well to see if code dies somewhere before completing that method.
Re: app crashes on orientation change
First things Vineet I am not using HandleResourceChangeL function [HTML]SetRect() invokes SizeChanged() which is the first statement in the HandleResourceChangeL()[/HTML]. I am using HandleResourceChange which is overridden in container.
And this is what i tried:
[CODE]void CMainFeaturesContainer::HandleResourceChange(TInt aType)
{
RFile file;
TBuf8<64>data8;
data8.Zero();
file.Create(CCoeEnv::Static()->FsSession(), _L("c:\\data\\orientation2.txt"), EFileWrite);
data8.Copy(_L8("5#"));
file.Write(data8);
// Call base class implementation
CCoeControl::HandleResourceChange(aType);
SetRect(iAvkonViewAppUi->View(TUid::Uid(EMainViewId))->ClientRect());
data8.Copy(_L8("6#"));
file.Write(data8);
iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse );
CreateListboxL();
data8.Copy(_L8("7#"));
file.Write(data8);
CEikAppUi* appUi = CEikonEnv::Static()->EikAppUi();
CEikApplication* app = appUi->Application();
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
TFileName bitmapFile;
bitmapFile = (app->BitmapStoreName());
bitmapFile.SetLength(bitmapFile.LocateReverse('\\') + 1);
bitmapFile.Append(_L("Listbox_bitmaps.mif"));
data8.Copy(_L8("8#"));
file.Write(data8);
CAknsItemDef* pMenuSkinItemCBA = AknsUtils::CreateBitmapItemDefL( KAknsIIDQsnBgAreaMain, bitmapFile,
EMbmListbox_bitmapsBackgroungcolor );
data8.Copy(_L8("9#"));
file.Write(data8);
TRAPD(err, skin->SetLocalItemDefL( pMenuSkinItemCBA));
TBuf<10> buf; buf.Zero();
buf.AppendNum(err);
data8.Copy(buf);
file.Write(data8);
iListBox->SetRect(Rect());
data8.Copy(_L8("11#"));
file.Write(data8);
SetIconsL();
data8.Copy(_L8("12#"));
file.Write(data8);
SetItemsL();
data8.Copy(_L8("13#"));
file.Write(data8);
file.Close();
}
[/CODE]
and the output of the file is 5#6#7#8#9# and the app crashes with KERN EXEC 0
Re: app crashes on orientation change
and i believe the panic KERN EXEC 0 has to do with the RFile that i am using for logging because if i remove the file logging part, the panic is KERN EXEC 3. I don't know TRAPD isn't working in the code or what.
Re: app crashes on orientation change
I wrote the HandleResourceChangeL by myself so added that extra L by mistake.
what happens if you comment out this line : TRAPD(err, skin->SetLocalItemDefL( pMenuSkinItemCBA)); , does the code proceeds further?
Re: app crashes on orientation change
Ok i mentioned because the one you mentioned is overridden in AppUi and to make sure we are on the same page. Anyways yes if i comment this line, the code proceeds further as suggested by file logging again but here is the interesting part.
If i comment this line and comment out file logging part as well because it was giving KERN EXEC 0 panic, the code works fine on changing the orientation but stays fine just for 2 seconds. After 2 seconds, app crashes with MEMORY FULL and KERN EXEC 3 together.
Re: app crashes on orientation change
Something seems to wrong with your sizechanged()/Draw() code i think , can you paste that part of code as here (Also are there any timers running in your code which update the UI or else)
Re: app crashes on orientation change
No, there are no timers updating my ui.
This is the Draw code:
[CODE]void CMainContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.Clear();
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
AknsDrawUtils::Background( skin, cc, this, gc, aRect );
gc.DrawRect( aRect );
}
[/CODE]
And this is the SizeChanged code:
[CODE]void CMainContainer::SizeChanged()
{
if (iListBox)
{
iListBox->SetRect(Rect());
}
DrawNow();
}
[/CODE]
do you see anything wrong in here?
Re: app crashes on orientation change
Alright i got it working. I removed everything except the iBackground thing and then setting the new Rect on list. It works.
Thanks for being with me Vineet.