Exiting app with User::Exit(EEikCmdExit)
| Thu, 2003-11-06 23:51 | |
|
Inside my CAppView class (as opposed to CAppUi) I don't seem to have access to AppUi()->HandleCommandL( EAknCmdExit ); So instead, I using User::Exit(EEikCmdExit); to exit my app. This appears to work fine and has no leaks. Is there anything fun fundamentally wrong with making this call? (The SDK samples do not demonstrate this call). The help docs says the app thread and resources are cleaned up - which was my main concern, but I just want to be sure. cheers paris. ~~~~ |
|






Forum posts: 17
This appears to work fine and has no leaks.
Have a look at MEikCommandObserver
Forum posts: 175
is a good idea (well at least from anywhere other than
AppUI or AppView).
Given my app structure:
CAppUI
.....CAppView
..........CEngine
................{
................//I am calling User::Exit(EEikCmdExit)
................//from inside here to close the app
................//upon a given user key press - but not
................//from the system menu!
................}
The interesting thing is the app 'does' close without
panics or leaks, but I recently noticed during a debug session
that no destructors are being called!. The docs say that
User::Exit(EEikCmdExit) will kill the thread, however,
because ~CEngine() ~CApppView() and ~CAppUI()
never get called (during debug) none of my
cleanup functions are being called either!
e.g.
CEngine::~CEngine
{
delete m_bmp1;
delete m_bmp2;
...
}
(BTW this is in WINS mode - VC++)
Bear in mind that I have disabled
//cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
..as I didn't want the user to exit the app frmo the system menu.
Any ideas on how to fake the same call from with in CEngine
without using User::Exit(EEikCmdExit)?
cheers,
paris.
~~~~
Forum posts: 17
: in CEngine without using User::Exit(EEikCmdExit)?
As I said in my previous post, use MEikCommandObserver. I don't have access to my development machine at the moment, so this is a bit vague/from memory.
In your view, you need a new member:
MEikCommandObserver* iCmdObserver
In your appui constructor, pass a pointer to the appui (i.e. a "this" pointer) to your view when you
construct it.
Your view needs to store this pointer in the iCmdObserver variable.
Your view is now free to call iCmdObserver::ProcessCommandL(EEIkExit), which will call your appui's CEiKAppUi::HandleCommandL(EEIkExit)
I use this technique to allow my views to call HandleCommandL in response to keyboard and pointer events, but it will also work the same for your engine if you pass iCmdObserver pointer to it when you construct it.
Greg
Forum posts: 175
I was just testing another approach where I do something like this:
CAppUI
{
iView->SetAppUiPtr(this);
}
then..
CAppView
{
m_engine->SetAppUiPtr(m_AppUiPtr);
}
Not sure if it will work yet (maybe its kinda the same thing as you mentioned)
My approach is standard C++ pointer passing, so if it doesn't work
it's probably to do with Eikon framework fussiness.
I'll try your recommendation in a moment.
rgds,
paris.
~~~~
Forum posts: 175
(I don't need to peek at commands just yet).
Other than that, my new approach works fine,
I've added a public CAppUI::ExitApp(){ Exit();} function.
When AppUi creates AppView it passes itself as a pointer
so the AppView can use it. AppView does exactly the same
thing, i.e passing the ssame pointer to CEngine.
CEngine can now call
static_cast<CAppUi*>(m_pAppUI)->ExitApp();
to close the app safely in the same way that the framework does.
Suits my purposes anyway
cheers.
paris.
~~~~
Forum posts: 21