Hi,
I have a listbox which I dynamically add icons to with the following code:
The bitmaps are also used in a different place, so I did SetBitmapsOwnedExternally(ETrue) so the listbox wont delete my bitmaps and they are deleted somewhere else.Code:CArrayPtr< CGulIcon >* icons = iListBox->ItemDrawer()->ColumnData()->IconArray(); CleanupStack::PushL( icons ); CGulIcon* icon; icon = CGulIcon::NewL(aBitmap, NULL); icon->SetBitmapsOwnedExternally(ETrue); CleanupStack::PushL( icon ); icons->AppendL( icon ); CleanupStack::Pop( icon ); CleanupStack::Pop( icons ); if ( icons != NULL ) { iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); return (icons->Count() - 1); } return 0;
In some cases I want to clear my listbox and load new icons.
This is my code for clearing the listbox (I'm leaving the first icon in the list because I still need it):
In the first time I load the icons and list data, everything works fine.Code:CArrayPtr< CGulIcon >* icons = iListBox->ItemDrawer()->ColumnData()->IconArray(); if (icons->Count() > 1) { for (TInt i=1;i<icons->Count();i++) { CGulIcon* icon = (*icons)[i]; delete icon; } icons->Delete(1, icons->Count()-1); icons->Compress(); } ((CDesCArray*)iFreelineFriendsContainer->ListBox()->Model()->ItemTextArray())->Reset(); iFreelineFriendsContainer->ListBox()->Reset();
but when I want to load a new data, it crashes.
I do not know where because the call stack shows me the RunApplication line.
but if I don't load the icons to the listbox, everything works well.
so I'm guessing I'm doing something wrong in the attached code.
Thanks.




