i copied out the engine class in IAPConnect example into a new project and when i run, it shows error and exits the program at SetConnectionPreferences at iPref = pref.
Below is the code:
void CGPRSconnectEngine::SetConnectionPreferences(TInt aBearer, TBool aDialog, TUint32 aIapId)
pref.iRanking = 1;
aDialog ? pref.iDialogPref = ECommDbDialogPrefPrompt : pref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
bearer.iBearerSet = aBearer;
bearer.iIapId = aIapId;
pref.iBearer = bearer;
iPref = pref; // <==== Error here
Does anyone know how to solve this? Thank you in advance.
The error displayed is:
Unhandled exception in epoc.exe (GPRSCONNECT.APP): 0xC0000005: Access Violation.
Have you actually created the CGPRSconnectEngine instance using new(ELeave) (or calling a static function that does)?
This is my constructor:
CGPRSconnectEngine* self = new (ELeave) CGPRSconnectEngine();
Yes, but do you call that NewLC() and then call that SetConnectionPreferences() member function on the returned instance?
No. I just call it like that:
iEngine -> SetConnectionPreferences(...);
Do i need to create a new instance of it?
Of course! If you have a CGPRSconnectEngine* iEngine declaration in your class, it merely says that iEngine is a pointer to a CGPRSconnectEngine. It does not initialize the pointer. You'll need to allocate memory for the instance data (for example, iPref) with a call to NewLC. In your code, iEngine is a NULL pointer and the first attempt to indirect through it (accessing a member variable) will cause a KERN-EXEC 3 panic.
Talking about the same example app, I also copied the engine and wait dialog code into my program. My app, as the exemple, doesn't terminate 'gracefully'. It shows a "Program closed" warning message...
Do you know why?
btw, I'm developing with sdk 1.2 and nokia 7650.
Maybe youi didn't destroy all the objects or something like that so the program crashes on exit.
I found that the app terminates 'gracefully' on the device... but dont on the emulator. No problems then...