×

Discussion Board

Results 1 to 6 of 6

Thread: After leave ?

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    29

    After leave ?

    Hi,
    suppose in my program creation of a C class object failed due to some problem. i have used cleanupstack .
    what will happen to my application after the leave i meant what will the end user see after the leave occured?
    hoping som hlp
    sym_coder

  2. #2
    Regular Contributor
    Join Date
    Feb 2005
    Posts
    328
    It depends where the C-object was constructed....

    If for example you are creating it in AppUi::ContructL, then this will leave and the user will be presented with an error message and the app will close. An example of this would be out of memory error, where the user will be prompted with a warning note, "Not enough memory..." (or similar).

    If on the other hand you are creating this object once your app is already running, say for example in AppUi::HandleCommandL, then the framework will catch the error and the user will again be prompted with a suitable error.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    29
    first of all thanks for the reply..
    so even if i use TrapD and cleanup stack the application will exit.. so what is the use?
    sym_coder

  4. #4
    Regular Contributor
    Join Date
    Feb 2005
    Posts
    328
    If you wrap the creation code in a TRAPD then you can handle the error yourself. In this case you can avoid the error being handled by the framework...

    eg

    void CMyAppUi::ConstructL()
    {
    TRAPD(ignored, iMyObject = CMyObject::NewL());
    // ignored = KErrNoMemory - we don't care ;-)
    // ConstructL does not leave, so no error reported
    // ... just don't try to use iMyObject or you'll get KERN-EXEC 3
    }

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    29
    hi thanks...for the reply
    if i have used cleanupstack ...and the memory allocation fails what will happen will a error message pop up and the user can continue with the application/ or the user automatically exits from the applocation if he exits automayically can i ask system to do some save operations before leaving the application? pleas help sym_coder

  6. #6
    Regular Contributor
    Join Date
    Feb 2005
    Posts
    328
    "if i have used cleanupstack ...and the memory allocation fails what will happen will a error message pop up and the user can continue with the application/ or the user automatically exits from the applocation "

    The app will automatically exit & user will be given a OOM error message.

    ... and to handle errors in construction:

    void CMyAppUi::ConstructL()
    {
    TRAPD(error, iMyObject = CMyObject::NewL());
    if (error)
    {
    // clean up
    }
    User::LeaveIfError(error);
    }

Posting Permissions

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