This very simple app to get cell ID raised Panic USER 42 on Exit. Pls help me to come out from this.
In the emulator the code shows Cell ID as 0, but while exiting it raises the panic: USER 42.
As USER 42 is abt heap cell pointer, I checked the code throughly, but can't trace any invalid pointer in the code that may cause this panic. I am using Visual Studio 2003 and Carbide 2.0.
Below the code is given
Code:// CCellIDAppUi.cpp void CCellIDAppUi::ConstructL() { // Initialise app UI with standard value. BaseConstructL(); // Create view object iAppView = CCellIDAppView::NewL( ClientRect() ); //Create Net Info retriever iNetInformer = CNetworkInfo::NewL(); } CCellIDAppUi::CCellIDAppUi() { // No implementation required } CCellIDAppUi::~CCellIDAppUi() { if ( iAppView ) { delete iAppView; iAppView = NULL; } if(iNetInformer) { delete iNetInformer; iNetInformer = NULL; } } void CCellIDAppUi::HandleCommandL( TInt aCommand ) { switch( aCommand ) { case EEikCmdExit: case EAknSoftkeyExit: Exit(); break; case ECellIDGetCellID: { iNetInformer->GetNetworkInfoL(); } break; //default: //Panic( ECellIDUi ); //break; } } //NetworkInfo.h #include <e32base.h> // For CActive, link against: euser.lib #include <etel3rdparty.h> // CTelephony, Link against etel3rdparty.lib class CNetworkInfo : public CActive { public: static CNetworkInfo* NewL(); ~CNetworkInfo(); void GetNetworkInfoL(); protected: // from CActive void RunL(); TInt RunError(TInt aError); void DoCancel(); private: CNetworkInfo(); void ConstructL(); private: CTelephony* iTelephony; CTelephony::TNetworkInfoV1 iNwInfo; CTelephony::TNetworkInfoV1Pckg iNwInfoPckg; }; // NetworkInfo.cpp #include <aknnotewrappers.h> #include "NetworkInfo.h" CNetworkInfo::CNetworkInfo() : CActive(EPriorityStandard), iNwInfoPckg(iNwInfo) { CActiveScheduler::Add(this); } CNetworkInfo* CNetworkInfo::NewL() { CNetworkInfo* self = new (ELeave) CNetworkInfo; CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(); return self; } void CNetworkInfo::ConstructL() { iTelephony = CTelephony::NewL(); } CNetworkInfo::~CNetworkInfo() { Cancel(); delete iTelephony; } // This function is used by our class' users to start getting network info. void CNetworkInfo::GetNetworkInfoL() { __ASSERT_ALWAYS(!IsActive(), User::Leave(KErrInUse)); // Start async call to receive current network information iTelephony->GetCurrentNetworkInfo(iStatus, iNwInfoPckg); SetActive(); } void CNetworkInfo::DoCancel() { iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel); } void CNetworkInfo::RunL() { User::LeaveIfError(iStatus.Int()); // Request completed successfully. _LIT(KFormatter, "Current Cell ID is: %d"); HBufC *msg = HBufC::NewLC(31); msg->Des().Format(KFormatter, iNwInfo.iCellId); CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( *msg ); CleanupStack::PopAndDestroy(msg); } TInt CNetworkInfo::RunError(TInt aError) { // There was an error retrieving current network info. _LIT(KFormatter, "CActive::RunError !!!"); HBufC *msg = HBufC::NewLC(31); msg->Des().Format(KFormatter); CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( *msg ); CleanupStack::PopAndDestroy(msg); return KErrNone; }





