×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    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 here, 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"));
            		Ret = iListBox->OfferKeyEventL( aKeyEvent, aType );  //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"));
            		Ret = iListBox->OfferKeyEventL( aKeyEvent, aType );  //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"));
    				iAppUi->ActivateLocalViewL(TUid::Uid(EPengawas_RincianViewId)); //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
    	}
    Please help me solve this terrible error.
    Thanks in advance.

    Regards,
    Asep

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,987

    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.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Thanks, Vineet, for your very very prompt reply... Will give it a try. Back to work first now.

  4. #4
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by vineet.jain View Post
    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.
    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;
    	}
    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.
    Last edited by asepm; 2013-02-06 at 07:35. Reason: More Details

  5. #5
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,987

    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

  6. #6
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by vineet.jain View Post
    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
    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.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    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.

  8. #8
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by wizard_hu_ View Post
    "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.
    That's a term I created myself, Wizard... LOL... 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...
    Last edited by asepm; 2013-02-06 at 08:52.

  9. #9
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    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.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    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 http://www.developer.nokia.com/Commu...rt-not-working 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...

  11. #11
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by wizard_hu_ View Post
    When autostarting GUI code, there can be some race condition with the code request prompts (PIN, lock) and the splash screen. See #9 of http://www.developer.nokia.com/Commu...rt-not-working 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...
    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".
    Last edited by asepm; 2013-02-06 at 09:52.

  12. #12
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    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.

  13. #13
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by asepm View Post
    but to eliminate the target's suspicion, I name it something like "*** System Manager".
    ?
    :-)

    regards
    pg

  14. #14
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    Re: Device Reboots - ListBox OfferKeyEventL

    Quote Originally Posted by pavarang View Post
    ?
    :-)

    regards
    pg
    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"... . 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.
    Last edited by asepm; 2013-02-06 at 13:58.

  15. #15
    Registered User
    Join Date
    Sep 2012
    Location
    Bandung, Indonesia
    Posts
    27

    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.

Similar Threads

  1. Listbox last bottom item is not refreshing on device ?
    By mail2karthi07 in forum Symbian
    Replies: 0
    Last Post: 2010-12-21, 12:15
  2. N96 device reboots when taking picture
    By Larsson73 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-06-11, 09:00
  3. how to get the number of item fit in listbox for particular device?
    By pandhari.gorde in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-01-21, 09:40
  4. Different Listbox behaviour between Emul and Device
    By ilsocio in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-11-07, 09:06
  5. ListBox OfferKeyEventL
    By aditya4180 in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-09-12, 14:48

Posting Permissions

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