×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    about delete the point of ListBox

    I try to switch a view to a anther. but when i debug my code,i get the infomation below:

    Unhandle exception in EPOC.EXE (EGUL.DLL): 0xC0000005 Access Violation,

    and stop at this line : delete iListBox; // at Container destruct function

    the "iListBox" point to a CAknDoubleLargeStyleListBox object.

    plz help me ,thanks!

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: about delete the point of ListBox

    It seems like a double-deletion. Have you got other "delete iListBox;"-lines in your code?

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144

    Re: about delete the point of ListBox

    and its better to double them with a line that sets the deleted pointer to NULL, to avoid multiple deletions (of course in destructor you don't need to do it).

    yucca

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    Unhappy Re: about delete the point of ListBox

    no , just once ! >_<

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144

    Re: about delete the point of ListBox

    ok then, do you delete the icon array or the text array before you delete the listbox ?

    yucca

  6. #6
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: about delete the point of ListBox

    Then please post some descriptive code snippet, otherwise it's difficult to tell.

  7. #7
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    Wink Re: about delete the point of ListBox

    wo solved problem.I should not delete the Container pointer in the function DoDeactivate() of View.
    it should be delete in the destruct function of View.

    Thanks to everybody!

  8. #8
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    Re: about delete the point of ListBox

    i am sorry, i didn't solved the problem.
    i refresh the ListBox's Text in a given frequency, so it looks like rolling text. this is some of my code:

    void CListContainer::SetupListItemsL()// construct the items of ListBox,
    {
    TInt pos;
    if(m_bfirst)
    pos=0;
    else
    {
    pos=iContentListBox->CurrentItemIndex();
    }
    if(pos!=m_icurIndex)
    {
    m_icurIndex=pos;
    m_ipos=0;
    }
    m_bfirst=EFalse;

    CTextListBoxModel* model = iContentListBox->Model();
    model->SetOwnershipType (ELbmOwnsItemArray);
    CDesCArray* contentArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
    contentArray->Reset();
    TBuf<512> aString;
    TBuf<512> tmpbuf;
    TInt myindex=0;//the index of icon

    for (TInt i = 0; i< iContentArray.Count(); i++)
    {
    myindex++;
    if(!m_isfinishconvert)
    {
    aString.Format(_L("%d\t"),1);
    }
    else
    {
    aString.Format(_L("%d\t"),myindex);
    }
    if(i==pos)
    {
    tmpbuf.Copy(iContentArray[i]->iDes.Mid(m_ipos));
    if(m_ipos<iContentArray[i]->iDes.Length()-1)
    m_ipos +=1;
    else
    m_ipos = 0;
    aString.Append(tmpbuf);
    }
    else
    aString.Append(iContentArray[i]->iDes);
    contentArray->AppendL (aString);
    }
    //iContentListBox->DrawNow();
    }
    void Cp2pListContainer::SetupPreViewListIconsL() // construct the icon Array;
    {
    HBufC* iconFileName;
    iconFileName = StringLoader::LoadLC(R_ICON_FILE_NAME);
    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(iContentArray.Count()+1);
    CleanupStack::PushL(icons);
    icons->AppendL(iEikonEnv->CreateIconL( *iconFileName,EMbmTick,EMbmTick_mask ));
    for(TInt i = 0; i< iContentArray.Count(); i++)
    {

    if(Bitmaps[i]!=NULL)
    {
    CGulIcon* icon=CGulIcon::NewL(Bitmaps[i]);
    icons->AppendL(icon);
    }
    else
    icons->AppendL(iEikonEnv->CreateIconL( *iconFileName, EMbmLvideo, EMbmLvideo_mask));
    }


    }
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);

    iContentListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    m_isfinishconvert=ETrue;
    }
    void CListContainer::UpdateBoxL()
    {
    SetupListItemsL();
    iContentListBox->DrawNow();
    }

    void CDynList::RunL() //CDynList is a Active Object,
    {
    iContainer.UpdateBoxL();// refresh the ListBox text
    TInt delay = KTimerInterval;
    iTimeWaster.After(iStatus, delay);
    SetActive();
    }


    void CListView:oDeactivate()
    {
    if(iContainer)
    {
    AppUi()->RemoveFromViewStack(*this, iContainer);
    delete iContainer;
    iContainer = NULL;
    }
    if(iNaviDecorator)
    {
    delete iNaviDecorator;
    iNaviDecorator = NULL;
    }
    }
    CListContainer::~CListContainer()
    {
    for(TInt i=0;i<50;i++) //the icons of ListBox
    {
    if(Bitmaps[i]!=NULL)
    {
    delete Bitmaps[i];
    }
    }
    if(iShowDynList != NULL)// a active object, which refresh the ListBox
    {
    iShowDynList->Cancel();
    delete iShowDynList;
    iShowDynList = NULL;
    }


    if(iAdapter != NULL)// anther active object, which deal with image converts
    {
    iAdapter->Cancel();
    delete iAdapter;
    iAdapter = NULL;
    }
    delete iContentListBox; //**** at this line, the epoc.exe return error info i mentioned yestoday *** Why?;
    }

  9. #9
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    Re: about delete the point of ListBox

    i am sorry, i didn't solve the problem.
    i refresh the ListBox's Text in a given frequency, so it looks like rolling text. this is some of my code:

    void CListContainer::SetupListItemsL()// construct the items of ListBox,
    {
    TInt pos;
    if(m_bfirst)
    pos=0;
    else
    {
    pos=iContentListBox->CurrentItemIndex();
    }
    if(pos!=m_icurIndex)
    {
    m_icurIndex=pos;
    m_ipos=0;
    }
    m_bfirst=EFalse;

    CTextListBoxModel* model = iContentListBox->Model();
    model->SetOwnershipType (ELbmOwnsItemArray);
    CDesCArray* contentArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
    contentArray->Reset();
    TBuf<512> aString;
    TBuf<512> tmpbuf;
    TInt myindex=0;//the index of icon

    for (TInt i = 0; i< iContentArray.Count(); i++)
    {
    myindex++;
    if(!m_isfinishconvert)
    {
    aString.Format(_L("%d\t"),1);
    }
    else
    {
    aString.Format(_L("%d\t"),myindex);
    }
    if(i==pos)
    {
    tmpbuf.Copy(iContentArray[i]->iDes.Mid(m_ipos));
    if(m_ipos<iContentArray[i]->iDes.Length()-1)
    m_ipos +=1;
    else
    m_ipos = 0;
    aString.Append(tmpbuf);
    }
    else
    aString.Append(iContentArray[i]->iDes);
    contentArray->AppendL (aString);
    }
    //iContentListBox->DrawNow();
    }
    void Cp2pListContainer::SetupPreViewListIconsL() // construct the icon Array;
    {
    HBufC* iconFileName;
    iconFileName = StringLoader::LoadLC(R_ICON_FILE_NAME);
    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(iContentArray.Count()+1);
    CleanupStack::PushL(icons);
    icons->AppendL(iEikonEnv->CreateIconL( *iconFileName,EMbmTick,EMbmTick_mask ));
    for(TInt i = 0; i< iContentArray.Count(); i++)
    {

    if(Bitmaps[i]!=NULL)
    {
    CGulIcon* icon=CGulIcon::NewL(Bitmaps[i]);
    icons->AppendL(icon);
    }
    else
    icons->AppendL(iEikonEnv->CreateIconL( *iconFileName, EMbmLvideo, EMbmLvideo_mask));
    }


    }
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);

    iContentListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    m_isfinishconvert=ETrue;
    }
    void CListContainer::UpdateBoxL()
    {
    SetupListItemsL();
    iContentListBox->DrawNow();
    }

    void CDynList::RunL() //CDynList is a Active Object,
    {
    iContainer.UpdateBoxL();// refresh the ListBox text
    TInt delay = KTimerInterval;
    iTimeWaster.After(iStatus, delay);
    SetActive();
    }


    void CListView:oDeactivate()
    {
    if(iContainer)
    {
    AppUi()->RemoveFromViewStack(*this, iContainer);
    delete iContainer;
    iContainer = NULL;
    }
    if(iNaviDecorator)
    {
    delete iNaviDecorator;
    iNaviDecorator = NULL;
    }
    }
    CListContainer::~CListContainer()
    {
    for(TInt i=0;i<50;i++) //the icons of ListBox
    {
    if(Bitmaps[i]!=NULL)
    {
    delete Bitmaps[i];
    }
    }
    if(iShowDynList != NULL)// a active object, which refresh the ListBox
    {
    iShowDynList->Cancel();
    delete iShowDynList;
    iShowDynList = NULL;
    }


    if(iAdapter != NULL)// anther active object, which deal with image converts
    {
    iAdapter->Cancel();
    delete iAdapter;
    iAdapter = NULL;
    }
    delete iContentListBox; //**** at this line, the epoc.exe return error info i mentioned yestoday *** Why?;
    }

  10. #10
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    Red face Re: about delete the point of ListBox

    .....
    just double deletion!!!!!!
    because the two line in function SetupPreViewListIconsL():

    CGulIcon* icon=CGulIcon::NewL(Bitmaps[i]);
    icons->AppendL(icon);

    i found the description of the construct function of class CGulIcon in the SDK :
    static CGulIcon* NewL(CFbsBitmap* aBitmap, CFbsBitmap* aMask=NULL);
    Description
    Creates a new icon using the bitmap and mask.
    It takes ownership of the bitmap and mask and returns a pointer to the object.


    i shouldn't delete the Bitmaps[] and delete the iListBox at the same time !!!!

    now the problem is solved!

Similar Threads

  1. Problem: Delete Operation With ListBox.
    By Tanya in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-12-01, 11:00
  2. a error about listbox and a findbox
    By billqu in forum Symbian
    Replies: 24
    Last Post: 2006-06-03, 07:06
  3. User break point error in Grid
    By ag24master in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-08-07, 08:20
  4. How to delete the last item in a listbox
    By zhang_guoqing in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-07-21, 07:28
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

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