Exiting app with User::Exit(EEikCmdExit)

Login to reply to this topic.
Thu, 2003-11-06 23:51
Joined: 2003-09-15
Forum posts: 175
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.

~~~~


Wed, 2003-11-19 23:59
Joined: 2003-07-09
Forum posts: 17
Re: Exiting app with User::Exit(EEikCmdExit)
Quote from: parisnlc
So instead, I using User::Exit(EEikCmdExit); to exit my app.
This appears to work fine and has no leaks.

Have a look at MEikCommandObserver
Wed, 2003-11-26 16:32
Joined: 2003-09-15
Forum posts: 175
Exiting app with User::Exit(EEikCmdExit)
I'm no longer convinced that calling  User::Exit(EEikCmdExit)
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.

~~~~

Wed, 2003-11-26 17:34
Joined: 2003-07-09
Forum posts: 17
Exiting app with User::Exit(EEikCmdExit)
: Any ideas on how to fake the same call from with
: 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
Wed, 2003-11-26 17:45
Joined: 2003-09-15
Forum posts: 175
Exiting app with User::Exit(EEikCmdExit)
Cheers Greg. (didn't see your previous post)

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.

~~~~

Wed, 2003-11-26 18:50
Joined: 2003-09-15
Forum posts: 175
Exiting app with User::Exit(EEikCmdExit)
I'm saving your idea in case it  comes in handy later
(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
Wink

cheers.

paris.

~~~~

Sun, 2005-09-04 11:25
Joined: 2005-09-04
Forum posts: 21
Re: Exiting app with User::Exit(EEikCmdExit)
Thanks for the idea, it goes well
  • Login to reply to this topic.