×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    29

    KERN EXEC 3 while deleting listbox

    Hi,

    I have created multiview application, i used listbox under tabsgroup. but it gives 'Kern exec 3' at deleting listbox.

    following is my containers .cpp
    Code:
    #include "CBuddyContainer.h"
    #include <Listbox.mbg>
    #include <aknnavide.h>
    #include <AknIconArray.h>
    #include <eikclbd.h>
    
    CBuddyContainer* CBuddyContainer::NewL(const TRect & aRect)
    {
       	CBuddyContainer* self = CBuddyContainer::NewLC(aRect);
       	CleanupStack::Pop();
       	return self;
    }
     
    CBuddyContainer* CBuddyContainer::NewLC(const TRect & aRect)
    {
       	CBuddyContainer* self = new (ELeave) CBuddyContainer();
       	CleanupStack::PushL(self);
       	self->ConstructL(aRect);
       	return self;
    }
     
    CBuddyContainer::CBuddyContainer()
    {
    
    }
    
    CBuddyContainer::~CBuddyContainer()
    {
    	iTabGroup = NULL;
    	
    	if(!iNaviPane)
        {
        	CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane();
        	iNaviPane = (CAknNavigationControlContainer*) sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
        }
     
    	if(iNaviPane) iNaviPane->Pop(NULL);
    	
    	iNaviPane = NULL;
    	
        delete iNaviDecoratorForTabs;
        iNaviDecoratorForTabs = NULL;
        
        delete iNaviDecorator;
        iNaviDecorator = NULL;
        
        delete iDetailListBox;
        iDetailListBox = NULL;
    
        DeleteSharesItemL();
    
        delete iShareListBox; // HERE IT GIVES KERN EXEC 3
        iShareListBox = NULL;
    }
    
    void CBuddyContainer::ConstructL(const TRect & aRect)
    {
    	CreateWindowL();
    	MakeNavipanelL();
    	// construct iFirstControl & iShareListBox in here..
    	
    	CreateDetailsListBox();
    	CreateSharesListBox();
    	
    	SetIconArrayL();
    	AddDetailsItemL();
    	
    	SetRect(aRect);
    	ActivateL();
    	DrawNow();
    }
    
    _LIT(KtxTabText1,"Details");
    _LIT(KtxTabText2,"Shares");
    	
    void CBuddyContainer::MakeNavipanelL(void)
    {
    	CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane();
    	iNaviPane = (CAknNavigationControlContainer*) sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
     
    	CAknNavigationDecorator* iNaviDecoratorForTabsTemp;
    	iNaviDecoratorForTabsTemp = iNaviPane->CreateTabGroupL();
    	delete iNaviDecoratorForTabs;
    	
    	iNaviDecoratorForTabs = NULL;
    	iNaviDecoratorForTabs = iNaviDecoratorForTabsTemp;
       	iTabGroup = STATIC_CAST(CAknTabGroup*, iNaviDecoratorForTabs->DecoratedControl());
    	iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoTabs);
     
    	iTabGroup->AddTabL(0,KtxTabText1);
    	iTabGroup->AddTabL(1,KtxTabText2);
    	 
    	iTabGroup->SetActiveTabByIndex(0);
    	iNaviPane->PushL(*iNaviDecoratorForTabs);
    }
     
    void CBuddyContainer::Draw(const TRect& /*aRect*/) const
    {
    	CWindowGc& gc = SystemGc();
    	gc.Clear(Rect());
    }
    
    CCoeControl* CBuddyContainer::ComponentControl( TInt /*aIndex*/) const
    {
    	CCoeControl* RetCont = NULL;
     
    	if(iTabGroup)
    	{
    		switch(iTabGroup->ActiveTabIndex())
    		{
    		case 1:
    			RetCont = iShareListBox;
    			break;
    		default:
    			RetCont = iDetailListBox;
    			break;
    		}	
    	}
    	
    	return RetCont;
    }
     
    TInt CBuddyContainer::CountComponentControls() const
    {
    	TInt RetCount = 0;
    	if(iTabGroup)
    	{
    		switch(iTabGroup->ActiveTabIndex())
    		{
    		case 1:
    			if(iShareListBox)
    			{
    				RetCount = 1;
    			}
    			break;
    		default:
    			if(iDetailListBox)
    			{
    				RetCount = 1;
    			}
    			break;
    		}	
    	}
    	return RetCount;
    }
    
    void CBuddyContainer::SizeChanged()
    {  
    	if(iDetailListBox)
    		iDetailListBox->SetExtent(TPoint(0,0),iDetailListBox->MinimumSize());
    	if(iShareListBox)
    		iShareListBox->SetExtent( TPoint(0,0), iShareListBox->MinimumSize() );
    			
    	DrawNow();
    }
    
    TKeyResponse CBuddyContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,
    		TEventCode aEventCode)
    {
    	if ( iTabGroup == NULL )
    	    {
    	    	return EKeyWasNotConsumed;
    	    }
    			
    		TInt active = iTabGroup->ActiveTabIndex();
    		TInt count = iTabGroup->TabCount();
    			
    		switch ( aKeyEvent.iCode )
    	    {
    		    case EKeyLeftArrow:
    	        if ( active > 0 )
                {
    	            active--;
    	            iTabGroup->SetActiveTabByIndex( active );
    	            DrawNow();
                }
    	        break;
    		    case EKeyRightArrow:
    	        if( (active + 1) < count )
                {
    	            active++;
    	            iTabGroup->SetActiveTabByIndex( active );
    	            DrawNow();
                }
    	        break;
    		    default:
    		    switch(active)
    		    {
    			    case 0: 
    			    {
    			    	if(iDetailListBox)
    				    	return iDetailListBox->OfferKeyEventL(aKeyEvent,aEventCode);
    				    }
    				    case 1: 
    					{
    					 if(iShareListBox)
    					   	return iShareListBox->OfferKeyEventL(aKeyEvent,aEventCode);
    					 }
    			return EKeyWasConsumed;
    			    }
    			}
    }
    
    void CBuddyContainer::CreateDetailsListBox()
    {
    	iDetailListBox = new (ELeave) CAknSingleHeadingStyleListBox();
    	iDetailListBox->ConstructL(this,EAknListBoxSelectionList);
    	iDetailListBox->SetContainerWindowL(*this);
    		
    	iDetailListBox->CreateScrollBarFrameL(ETrue);
    	iDetailListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn,CEikScrollBarFrame::EAuto);
    		
    	CDesCArray* itemArray = new (ELeave) CDesCArrayFlat(5);
    	
    	iDetailListBox->Model()->SetItemTextArray(itemArray);
    		
    	iDetailListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);			
    }
    
    void CBuddyContainer::AddDetailsItemL()
    {
    	MDesCArray* listArray = iDetailListBox->Model()->ItemTextArray();
    	CDesCArray* itemArray = static_cast<CDesCArray*>(listArray);
    
    	// For CAknSingleHeadingStyleListBox
    	_LIT(KItemFormat,"%S\t%S\t%d\t"); // 1\t21/10\tMeeting\t
    	_LIT(KItemFormat1,"%S\t%S\t"); // 1\t21/10\tMeeting\t
    	TBuf<100> value;
    		
    	value.Format(KItemFormat1,&(_L("Name")),&(_L("Tom")));	
    	itemArray->AppendL(value);
    		
    	value.Format(KItemFormat1,&(_L("Location")),&(_L("Atlanta")));	
    	itemArray->AppendL(value);
    		
    	value.Format(KItemFormat,&(_L("Phone")),&(_L("726459812")),1);	
    	itemArray->AppendL(value);
    		
    	value.Format(KItemFormat1,&(_L("E-mail")),&(_L("Tom@yahoo.com")));	
    	itemArray->AppendL(value);
    		
    	iDetailListBox->HandleItemAdditionL();
    }
    
    void CBuddyContainer::CreateSharesListBox()
    {
    	iShareListBox = new (ELeave) CAknSingleGraphicStyleListBox();
    	iShareListBox->ConstructL(this,EAknListBoxSelectionList);
    	iShareListBox->SetContainerWindowL(*this);
    		
    	iShareListBox->CreateScrollBarFrameL(ETrue);
    	iShareListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn,CEikScrollBarFrame::EAuto);
    		
    	CDesCArray* itemArray = new (ELeave) CDesCArrayFlat(5);
    	//	CleanupStack::PushL(itemArray);
    		
    	iShareListBox->Model()->SetItemTextArray(itemArray);
    	//	CleanupStack::Pop(itemArray);
    	iShareListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
    	
    	//SetIconArrayL();
    	//AddSharesItemL();
    }
    
    void CBuddyContainer::SetIconArrayL()
    {
    	_LIT(KFileName,"\\Resource\\ListBox.mbm");
    
    	iIconArray = new (ELeave) CAknIconArray(4);
    	CleanupStack::PushL(iIconArray);
    
    	iIconArray->AppendL(iEikonEnv->CreateIconL(KFileName,EMbmListboxSingle,EMbmListboxSingle_mask));
    	iIconArray->AppendL(iEikonEnv->CreateIconL(KFileName,EMbmListboxMultiple,EMbmListboxMultiple_mask));
    	iIconArray->AppendL(iEikonEnv->CreateIconL(KFileName,EMbmListboxOnline,EMbmListboxOnline_mask));
    	iIconArray->AppendL(iEikonEnv->CreateIconL(KFileName,EMbmListboxOffline,EMbmListboxOnline_mask));
    	iIconArray->AppendL(iEikonEnv->CreateIconL(KFileName,EMbmListboxBusy,EMbmListboxOnline_mask));
    
    	if(iShareListBox)
    		iShareListBox->ItemDrawer()->ColumnData()->SetIconArray(iIconArray);
    	if(iDetailListBox)
    		iDetailListBox->ItemDrawer()->ColumnData()->SetIconArray(iIconArray);
    
    	CleanupStack::Pop(); // iconArray
    }
    
    void CBuddyContainer::AddSharesItemL()
    {
    	MDesCArray* listArray = iShareListBox->Model()->ItemTextArray();
    	CDesCArray* itemArray = static_cast<CDesCArray*>(listArray);
    
    	_LIT(KItemFormat,"%d\t%S\t\t"); // 0\tDownload themes\t\t
    
    	TBuf<100> value;
    
    	value.Format(KItemFormat,0,&(_L("File1.txt")));
    	itemArray->AppendL(value);
    
    	value.Format(KItemFormat,1,&(_L("File2.bmp")));	
    	itemArray->AppendL(value);
    
    	value.Format(KItemFormat,2,&(_L("File3.amr")));	
    	itemArray->AppendL(value);
    
    	iShareListBox->HandleItemAdditionL();
    }
    
    void CBuddyContainer::DeleteSharesItemL()
    {
    	MDesCArray* listArray = iShareListBox->Model()->ItemTextArray();
    	CDesCArray* itemArray = static_cast<CDesCArray*>(listArray);
    
    	TInt nCount = itemArray->Count();
    	
    	for(TInt index=0; index < nCount; index++)
    	{
    		itemArray->Delete(0);
    		iShareListBox->HandleItemRemovalL();
    	}
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: KERN EXEC 3 while deleting listbox

    Why do you need to call "DeleteSharesItemL" in your destructor to delete array items. You have already set an ownership of the array to listbox. Let the listbox handle all these sanity checks. Do not call this function in your destructor. Juts delete the iShareListBox.

    Kiran.
    Nokia Developer Wiki Moderation team

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    29

    Re: KERN EXEC 3 while deleting listbox

    Are Kiran,

    Je puchyu che eno jawab aapne...!!! :-)

    There is no change if I call DeleteSharesItemL() or not.
    It always gives 'Kern Exec 3' on delete of 'iShareListBox'

    Don't you think i must have tried this?!!!

    I am working on this since last 4-5 days!!!!

    I also sent you source of test application. but you and Vasant, none of you replied for it.

    Please help, we are running very critical situation.

    Regards
    Hansa

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

    Re: KERN EXEC 3 while deleting listbox

    I would still think its about that, just declare icons & text arrays as local variables, and then do not do any deleting for them in any point. The listbox you are setting them to, will take care of it already.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    29

    Re: KERN EXEC 3 while deleting listbox

    Hi symbianyucca,

    Thank you sooooooooooo much

    i was trying this since last 4-5 days.

    at last i got it fixed because of ur hint

    Thanks
    Hansa

Similar Threads

  1. 'Kern exec 3' on exit of multipage dialog
    By hansapariya in forum Symbian
    Replies: 6
    Last Post: 2008-07-23, 08:10
  2. Replies: 4
    Last Post: 2008-03-10, 09:04
  3. Problem with ListBox and deleting ListBoxItems
    By SengirPaladin in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-07-23, 03:53
  4. Replies: 2
    Last Post: 2007-07-19, 01:29
  5. why kern exec 3 on CopyFile?
    By flicker82 in forum Symbian
    Replies: 2
    Last Post: 2005-05-16, 02:25

Posting Permissions

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