Device Reboots - ListBox OfferKeyEventL
Hello,
I've got a weird problem with ListBox which is extremely frustrating and annoying to me. It has always caused my phone to reboot everytime I hit Up, Down and OK key. This was also posted by someone else [URL="http://www.developer.nokia.com/Community/Discussion/showthread.php?160001-iListBox-gt-OfferKeyEventL-crashed-without-Skin-used"]here[/URL], but no single answer was given to him.
My code:
[CODE]
TKeyResponse CPengawas_Logs::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
TKeyResponse Ret = EKeyWasNotConsumed;
if(aType != EEventKey || iListBox == NULL || !iListBox->IsFocused())
{
return EKeyWasNotConsumed;
}
switch(aKeyEvent.iCode)
{
case EKeyUpArrow:
{
if (iItemCount > 1)
{
iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iListBox->CurrentItemIndex() = "),
ETrue, iListBox->CurrentItemIndex());
if (iListBox->CurrentItemIndex() > 0)
iSelectedItemIndex = iListBox->CurrentItemIndex() - 1;
else
iSelectedItemIndex = iItemCount - 1;
iAppUi->iActiveItemIndex = iSelectedItemIndex;
iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iAppUi->iActiveItemIndex = "), ETrue,
iAppUi->iActiveItemIndex);
iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - ShowDateTimeAndItemNumber"));
ShowDateTimeAndItemNumber(iItemCount);
iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - ShowDateTimeAndItemNumber - DONE"));
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL"));
[B][COLOR="#FF0000"]Ret = iListBox->OfferKeyEventL( aKeyEvent, aType );[/COLOR][/B] //This line always fails (nothing was written to log afterwards), resulting in phone reboot
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL - DONE"));
//Ret = EKeyWasConsumed;
}
// Forward up key press events to the list box
//return iListBox->OfferKeyEventL( aKeyEvent, aType );
return Ret;
}
case EKeyDownArrow:
{
if (iItemCount > 1)
{
iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - iListBox->CurrentItemIndex() = "),
ETrue, iListBox->CurrentItemIndex());
if (iListBox->CurrentItemIndex() < iItemCount - 1)
iSelectedItemIndex = iListBox->CurrentItemIndex() + 1;
else
iSelectedItemIndex = 0;
iAppUi->iActiveItemIndex = iSelectedItemIndex;
iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iAppUi->iActiveItemIndex = "), ETrue,
iAppUi->iActiveItemIndex);
iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - ShowDateTimeAndItemNumber"));
ShowDateTimeAndItemNumber(iItemCount);
iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - ShowDateTimeAndItemNumber - DONE"));
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL"));
[B][COLOR="#FF0000"]Ret = iListBox->OfferKeyEventL( aKeyEvent, aType );[/COLOR][/B] //This line fails all the time, leading to phone reboot as well
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL - DONE"));
//Ret = EKeyWasConsumed;
}
// Forward down key press events to the list box
//return iListBox->OfferKeyEventL( aKeyEvent, aType );
return Ret;
}
case EKeyOK:
{
if (iItemCount > 0)
{
iAppUi->SaveToLog(KFileLog, _L("EKeyOK - iListBox->CurrentItemIndex() = "),
ETrue, iListBox->CurrentItemIndex());
iSelectedItemIndex = iListBox->CurrentItemIndex();
iAppUi->iActiveItemIndex = iSelectedItemIndex;
iAppUi->SaveToLog(KFileLog, _L("EKeyOK - iAppUi->iActiveItemIndex = "),
ETrue, iAppUi->iActiveItemIndex);
iAppUi->SaveToLog(KFileLog, _L("EKeyOK - About to activate another view"));
[B][COLOR="#0000FF"]iAppUi->ActivateLocalViewL(TUid::Uid(EPengawas_RincianViewId));[/COLOR][/B] //This line "apparently" succeeds as the next line was executed, though phone reboot still occurs all the time...
iAppUi->SaveToLog(KFileLog, _L("EKeyOK - Another view might have been activated")); //The log was successfully appended
//return EKeyWasConsumed;
}
return EKeyWasConsumed;
}
default:
break;
}
//return EKeyWasNotConsumed;
//return Ret;
//CCoeControl::OfferKeyEventL( aKeyEvent, aType); activating/deactivating this line did not make a difference
}
[/CODE]
Please help me solve this terrible error.
Thanks in advance.
Regards,
Asep
Re: Device Reboots - ListBox OfferKeyEventL
What happens if you replace the OfferkeyEvent code with the following(just a test case):
TKeyResponse Ret = EKeyWasNotConsumed;
if(iListBox)
{
Ret = iListBox->OfferKeyEventL(aKeyEvent,aEventCode);
}
return Ret;
the up,down etc events of listbox are handled itself.
Re: Device Reboots - ListBox OfferKeyEventL
Thanks, Vineet, for your very very prompt reply... Will give it a try. Back to work first now. :)
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=vineet.jain;910640]What happens if you replace the OfferkeyEvent code with the following(just a test case):
TKeyResponse Ret = EKeyWasNotConsumed;
if(iListBox)
{
Ret = iListBox->OfferKeyEventL(aKeyEvent,aEventCode);
}
return Ret;
the up,down etc events of listbox are handled itself.[/QUOTE]
I followed your suggestion, with only a minor addition, as follows.
[CODE]
TKeyResponse CPengawas_Logs::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
TKeyResponse Ret = EKeyWasNotConsumed;
if (iListBox)
{
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL(aKeyEvent, aType)"));
Ret = iListBox->OfferKeyEventL(aKeyEvent, aType);
iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL(aKeyEvent, aType) - DONE"));
}
return Ret;
}
[/CODE]
Once I installed a new sis file with the above modification, I was happy to note that the problem has gone... (the line with "DONE" word was executed, just ONCE). But after I rebooted the phone myself (at my own will), and I hit the Down key, the phone freezed and rebooted again... Then when the phone was on again, I hit the Up key, same thing happened (i.e. phone freezed and rebooted at its own will...). Surprisingly, the OK key, when hit, did not give me that strange error...
Any more clues, Vineet, or anyone else?
Thanks.
Edited: On a side note, this error never happens on emulator.
Re: Device Reboots - ListBox OfferKeyEventL
I do not think simple key events can do a phone reboot, can you try a making a new helloworld project & create a listbox box in that to see if the same behavior is there as well.
Plus what kind of processing is happening inside this container. Can you try installing the same sis on some other device or even on RDA
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=vineet.jain;910646]I do not think simple key events can do a phone reboot, can you try a making a new helloworld project & create a listbox box in that to see if the same behavior is there as well.
Plus what kind of processing is happening inside this container. Can you try installing the same sis on some other device or even on RDA[/QUOTE]
I do agree with you. However, it seems that the error only occurs when the phone is not yet stable after a reboot (and then a key hit was made). I presume that maybe some other processes can bring about this error. Am I right? Oh, one more thing, I have a KeyCapturer AO and some others. But could it be that the culprit is not the management of those AO's, but the phone not being stable yet? Please shed more light on this.
BTW, gotta take a closer look at what I place all over this container. Will revert once I find anything suspicious.
Re: Device Reboots - ListBox OfferKeyEventL
"Not yet stable" - is this code autostarted?
You may want to try how other applications behave, like Contacts, Messages. Yes, capturekey can create all kind of mystical effects.
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=wizard_hu_;910649]"Not yet stable" - is this code autostarted?
You may want to try how other applications behave, like Contacts, Messages. Yes, capturekey can create all kind of mystical effects.[/QUOTE]
That's a term I created myself, Wizard... LOL... :D Oh your assumption is right. I set it to autostart on every reboot, as per one of Kiran's articles, and make it invisible (i.e. sent to background) once it is loaded.
Actually, yes, you're totally correct. KeyCapturer acts in a strange manner on random occasions. I just found out a while ago that one or some or all of the keys (all numeric keys) were not captured at all when my phone booted up. I think, to find out the real cause of the errors, I have to deactivate the key capturer first.
Thanks, Wizard. This is the program (a spy app, for my own needs) I began to write a few months back, which I am still constantly updating EVERY SINGLE DAY. LOL, again... :D
Re: Device Reboots - ListBox OfferKeyEventL
I'm getting more and more curious now. The KeyCapturer was deactivated (the creation line and all references to it were commented out), phone rebooted, but the problem persisted. The same error with Up+Down Keys.
Maybe some of FN users once experienced this kind of errors, too? Any help is hugely appreciated.
Re: Device Reboots - ListBox OfferKeyEventL
When autostarting GUI code, there can be some race condition with the code request prompts (PIN, lock) and the splash screen. See #9 of [url]http://www.developer.nokia.com/Community/Discussion/showthread.php?159457-AutoStart-not-working[/url] for a short description.
it is a common workaround to put a 5-10 seconds wait at the very beginning - like in E32Main. Of course it is not an exact thing, and in addition it causes an unwanted delay if the same application can be launched from the Menu too...
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=wizard_hu_;910657]When autostarting GUI code, there can be some race condition with the code request prompts (PIN, lock) and the splash screen. See #9 of [url]http://www.developer.nokia.com/Community/Discussion/showthread.php?159457-AutoStart-not-working[/url] for a short description.
it is a common workaround to put a 5-10 seconds wait at the very beginning - like in E32Main. Of course it is not an exact thing, and in addition it causes an unwanted delay if the same application can be launched from the Menu too...[/QUOTE]
Well, I guess I need to consider giving that 5-10 second delay. Moreover, this is not a commercial program at all. The target phone is on/active 24/7, unless it reboots itself as I explained earlier. Fortunately, I do all the test and debug on my own phone, not on that "single" (LOL) end-user's.
Starting this app from menu is not possible, I guess, as it is hidden from the menu. It still resides on the application list, though, but to eliminate the target's suspicion, I name it something like "*** System Manager".
Re: Device Reboots - ListBox OfferKeyEventL
Sorry to keep bothering you but, even after waiting for some 10 minutes after a reboot, the problem with they Up-Down keys lives on... Will deactivate all the AO's (10 in total) first to see what might cause the error.
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=asepm;910658]but to eliminate the target's suspicion, I name it something like "*** System Manager".[/QUOTE]
?
:-)
regards
pg
Re: Device Reboots - ListBox OfferKeyEventL
[QUOTE=pavarang;910669]?
:-)
regards
pg[/QUOTE]
Hi Paparang, glad that at least someone considers my last post funny. Indeed, I consider it funny, too, coz I name it "N***a System Manager"... :D. Hope it's not offensive or found to be against the law, because I do it only to conceal the true identity and behavior of that app I've been developing, for MY OWN needs. I will not publish it to anyone else (apart from my SINGLE target user) until I change the name. :)
Oh my goodness, the exact cause of my device rebooting by itself due to the error is actually the use of labels. Yes, I've got rid of all labels on my app (on 3 out of 4 containers) and now, there are no more freezing and unwanted reboots.
Instead of labels, I will now try using other methods to display the info related to each selected item on the listbox.
Re: Device Reboots - ListBox OfferKeyEventL
At last I think I have to admit that the cause of incessant reboots of my device is due to nothing but the long process in the Draw() method that I used. As Symbian's Creating Custom Controls workbook explains, the Draw() function should be made as fast as possible. That also means that the use of "custom fonts" as I used earlier is a bad idea and strongly discouraged. This is for anybody who might experience an error similar to what I've encountered for the last couple of days.