×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    51

    problem with Exit()

    hi.

    i have an application taht hangs whenever i use the exit function.

    here is my appui cpp code:


    // INCLUDE FILES
    #include "MyStoritAppUi.h"
    #include "MyStoritBaseView.h"
    #include "MyStoritListBoxView.h"
    #include "MyStoritListBoxViewImage.h"
    #include "mystorit.hrh"
    #include <mystorit.rsg>

    #include <avkon.hrh>


    // default constructor
    CMyStoritAppUi::CMyStoritAppUi()
    {
    }

    // ----------------------------------------------------------
    // CMyStoritAppUi::ConstructL()
    // ?implementation_description
    // ----------------------------------------------------------
    //
    void CMyStoritAppUi::ConstructL()
    {
    BaseConstructL();

    // Creates CMyStoritBaseView class object
    iBaseView = new (ELeave) CMyStoritBaseView;
    CleanupStack::PushL(iBaseView);
    iBaseView->ConstructL();
    AddViewL(iBaseView);
    CleanupStack::Pop();

    // Creates CMyStoritListBoxView class object
    iListView = new (ELeave) CMyStoritListBoxView;
    CleanupStack::PushL(iListView);
    iListView->ConstructL(R_MYSTORIT_LISTBOX_VIEW_PHONE);
    AddViewL(iListView);
    CleanupStack::Pop();
    iBaseView->SetListBoxView(iListView);

    // Creates CMyStoritListBoxViewImage class object
    iListViewImage = new (ELeave) CMyStoritListBoxViewImage;
    CleanupStack::PushL(iListViewImage);
    iListViewImage->ConstructL(R_MYSTORIT_LISTBOX_VIEW_PHONE);
    AddViewL(iListViewImage);
    CleanupStack::Pop();
    iBaseView->SetListBoxViewImage(iListViewImage);


    ActivateLocalViewL(iBaseView->Id());
    }

    // ----------------------------------------------------
    // CMyStoritAppUi::~CMyStoritAppUi()
    // Destructor
    // Frees reserved resources
    // ----------------------------------------------------
    //
    CMyStoritAppUi::~CMyStoritAppUi()
    {
    if (iBaseView)
    {
    RemoveView(iBaseView->Id());
    delete iBaseView;
    iBaseView = NULL;
    }

    if (iListView)
    {
    RemoveView(iListView->Id());
    delete iListView;
    iListView = NULL;
    }

    if (iListViewImage)
    {
    RemoveView(iListViewImage->Id());
    delete iListViewImage;
    iListViewImage = NULL;
    }
    }

    // ------------------------------------------------------------------------------
    // CMyStoritAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
    // This function is called by the EIKON framework just before it displays
    // a menu pane. Its default implementation is empty, and by overriding it,
    // the application can set the state of menu items dynamically according
    // to the state of application data.
    // ------------------------------------------------------------------------------
    //
    void CMyStoritAppUi::DynInitMenuPaneL(
    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
    {
    }

    // ----------------------------------------------------
    // CMyStoritAppUi::HandleKeyEventL(
    // const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
    // ?implementation_description
    // ----------------------------------------------------
    //
    TKeyResponse CMyStoritAppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
    {
    return EKeyWasNotConsumed;
    }

    // ----------------------------------------------------
    // CMyStoritAppUi::HandleCommandL(TInt aCommand)
    // ?implementation_description
    // ----------------------------------------------------
    //
    void CMyStoritAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case EAknCmdExit:
    case EEikCmdExit:
    case EAknSoftkeyExit:
    {
    Exit();
    break;
    }
    // TODO: Add Your command handling code here
    default:
    break;
    }
    }


    i tried debugging it and i get this exception whenever i try to delete my views:

    Unhandled exception in EPOC.EXE (MYSTORIT.APP): 0xC0000005: Access Violation

    i tried taking those lines out of my code and i then get this error in the Exit() function:

    the thread 0x1318 has exited with code 0 (0x0)

    can anyone pls tell me what i am doing wrong? thanks!

    yen

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    put breakpoints to your class destructors, then run your app and when exiting use F10 to run it line by line in your destructors, untill you come to the line that gives you the error.

    In case you have oportunity to run it in phone, check it there and I'm quite sure the error would be shown as Kern-Exec 3. Meaning that most propably since it's happening in exit time you are trying to delete already deleted pointer that was not set to NULL.

    So in case you need to delete your class variables during the app run, you need to set then to null after deleting to avoid the problem. i.e:

    Delete iVar;
    iVar = NULL;

    Other cause could be that you are deleting something twice. Or that you are deleting something that you dont own, array etc. that you set to some component that takes ownership to it and will handle the deletion by it self.

    yucca

Posting Permissions

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