×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    35

    app crash with softkey press

    I am writing an application that uses an active object to open (and write to) an TCP socket. It works fine - connects, writes to socket, and waits. As soon as I press the left softkey it crashes with:
    Code:
    App. closed:
    TCPClientGUI
    The crash happens before any of my code gets called or event HandleCommandL in the AppUI.cpp file (as generated by Carbide.c++).

    Any idea what may cause this? I assume its some resource that isn't cleaned up properly by why would it only happen when I press a key? Any idea what pressing the softkey does internally and what kind of resources it might try to use?

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    Dec 2006
    Posts
    35

    Re: app crash with softkey press

    Before someone asks, the target platform is S60 3rd Edition and here is the relevant code:
    Code:
    
    CCTCPSender::CCTCPSender() : CActive(EPriorityStandard)	// Standard priority
    {
    }
    
    void CCTCPSender::ConstructL(TInt aPort)
    {
    	CLogger::Log(_L8("ConstructL()\n"));	
    	CActiveScheduler::Add(this);				// Add to scheduler
    	iPort = aPort;
    	User::LeaveIfError(iSocketServer.Connect());
    	iState = EInitialized;
    	CLogger::Log(_L8("exit ConstructL()\n"));	
    }
    
    void CCTCPSender::sendMsg() {
    	CLogger::Log(_L8("sendMsg()\n"));		
    	TInetAddr addr;
    	const TUint32 KInetAddr = INET_ADDR(127,0,0,1);
    	addr.SetAddress(KInetAddr);
     	addr.SetPort (3210) ; // Assume always port 3210 for now!
     	if(iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp) == KErrNone) {
    		iSocket.Connect(addr, iStatus) ;		 		
    	iState = EConnecting;
     	}
    	SetActive();
    	CLogger::Log(_L8("exit sendMsg()\n"));	
    	
    }
    
    
    
    CCTCPSender* CCTCPSender::NewL(TInt iPort ) {
        CCTCPSender* self = NewLC( iPort );
        CleanupStack::Pop( self );
        return self;
    }
    
    CCTCPSender* CCTCPSender::NewLC(TInt aPort ) {
    	CCTCPSender* self = new ( ELeave ) CCTCPSender();
        CleanupStack::PushL( self );
        self->ConstructL(aPort);
        return self;
    }
    
    
    CCTCPSender::~CCTCPSender()
    {
    	CLogger::Log(_L8("Destructor\n"));
    	Cancel(); // Cancel any request, if outstanding
    	iSocketServer.Close();
    	CLogger::Log(_L8("iSocketServer closed\n"));
    	CLogger::Close();
    }
    
    void CCTCPSender::DoCancel()
    {
    	CLogger::Log(_L8("DoCancel\n"));
    	iState = EClosing;
    	iSocket.CancelAll();
    	iSocket.Close();
    	CLogger::Log(_L8("Exit DoCancel\n"));
    }
    
    
    
    
    void CCTCPSender::RunL() {
    	switch(iState) {
    		case EUninitialized: {
    			CLogger::Log(_L8("EUninitialized\n"));
    			// Do something the first time RunL() is called
    			iState = EInitialized;
    		} break;
    		case EInitialized: {
    			CLogger::Log(_L8("EInitialized\n"));
    		} break;
    		case EConnecting: {
    			CLogger::Log(_L8("EConnecting\n"));
    			
    			if (iStatus == KErrNone) {
    				iRequest.Copy(		_L8("Hello World!\n\r"));
    				iSocket.Write(iRequest, iStatus) ;
    				iState = ESending ;				
    				CLogger::Log(_L8("done writing\n"));
    			}
    		} break;
    		case ESending: {
    			CLogger::Log(_L8("ESending\n"));
    			if (iStatus == KErrNone) {
    			CLogger::Log(_L8("ESending no err\n"));
    			iSocket.CancelAll(); // just to be safe
    			iSocket.Close();
    			iSocketServer.Close();
    			CLogger::Log(_L8("done with temp closing no err\n"));
    			}
    		} break;
    		case EError:
    			CLogger::Log(_L8("EError\n"));
    		default: {
    			CLogger::Log(_L8("DEFULAT CASE\n"));
    		} break;
    		
    		
    	}
    	SetActive();					// Tell scheduler a request is active
    	CLogger::Log(_L8("exit RunL\n"));
    }
    It gets called by the following code:
    Code:
    void CTCPClientGuiAppUi::HandleCommandL( TInt aCommand )
        {
    	CLogger::Log(_L8("HandleCommandL\n"));	
        switch( aCommand )
            {
            case EEikCmdExit:
            case EAknSoftkeyExit:
    	CLogger::Log(_L8("   EAknSoftkeyExit\n"));	
            	delete iCTCPSender;
                Exit();
                break;
            case ECommand1: {
    	    CLogger::Log(_L8("   ECommand1\n"));	
                	iCTCPSender = CCTCPSender::NewL(3210);
        	} break;
            case ECommand2: {
    	    CLogger::Log(_L8("   ECommand2\n"));	
            	iCTCPSender->sendMsg();
        	} break;
            default:
    	    CLogger::Log(_L8("   default\n"));	
                Panic( ETCPClientGuiUi );
                break;
            }
    	CLogger::Log(_L8("ExitCommandL\n"));	
        }
    So you select ECommand1 to construct the object and everything is fine. Then you select ECommand2 and it connects to a socket (a server in a separate app is already listening). After that, as soon as you press a softkey, it crashes (you don't even get to select a menu item).

    Don't get hung up on the CLogger. It just writes to a file and the app crashes the same way when its commented out.

    Thanks
    Last edited by redfoodegm; 2007-01-23 at 22:00.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    41

    Re: app crash with softkey press

    Set the extended panic codes on and you'll get more info about the crash. Panic codes can be set on from emulator (window) menu: Tools -> Preferences: check the 'Extended panic code file' on.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: app crash with softkey press

    Quote Originally Posted by redfoodegm
    here is the relevant code:
    [...]
    After that, as soon as you press a softkey, it crashes (you don't even get to select a menu item).
    Indeed it is not the relevant code, since it is never reached in runtime. Getting the extended panic code is a good idea, but I would also check the .rss file, the menubar and cba field of EIK_APP_INFO (or an AVKON_VIEW), and the things menubar refers to.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    35

    Re: app crash with softkey press

    Quote Originally Posted by kosjanne
    Set the extended panic codes on and you'll get more info about the crash. Panic codes can be set on from emulator (window) menu: Tools -> Preferences: check the 'Extended panic code file' on.
    Thanks, I'm not sure how that got turned off. Now if I could just figure out what is causing a E32USER-CBase 46 panic. (As far as I can tell I have a SetActive() for every asynchronous call.)

Similar Threads

  1. 2 TRgb class variables crash app ??
    By sandopolus in forum Symbian
    Replies: 1
    Last Post: 2006-05-20, 23:28
  2. App not get closed whn ---> press App key n select 'C'
    By saurbh_g in forum Symbian User Interface
    Replies: 5
    Last Post: 2006-05-11, 09:51
  3. Replies: 1
    Last Post: 2006-04-27, 18:10
  4. App crash problem - how to figure out why?
    By neomedia in forum Symbian
    Replies: 1
    Last Post: 2005-02-07, 16:22
  5. Replies: 0
    Last Post: 2004-01-12, 17:47

Posting Permissions

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