MultipleView Problem, plz help

Login to reply to this topic.
Tue, 2006-03-07 07:00
Joined: 2006-02-19
Forum posts: 5
Hi everyone
I have this problem that when i'm using more than 2 views in a multipleview architecture, it gives me "USER 42" error message, and it leaves in the BaseConstructL() function in void CSmsObserverAppUi::ConstructL(), does anyone know why, and how to solve this problem, and the source code is provided , Plz help
thankx alot

//The MainList code

// Class include
#include "MainList.h"

// System includes
#include <akniconarray.h> // CAknIcon
#include <aknlists.h> // CAknSingleStyleListBox
#include <barsread.h> // TResource Reader
#include <eikclbd.h> // CColumnListBoxData
#include <eikmenub.h> // CEikMenuBar
#include <SmsObserver.rsg> // R_LELIST_LISTBOX
#include <stringloader.h> // StringLoader
#include <uikon.hrh> // TKeyCode #defines

#include <badesca.h> //CDesCArray

// N.B. #define'd as DLL cannot contain writeable static data
#define KListPosition TPoint(0,0)

_LIT(KEmptyText, "(No message is present)" );

// ================= MEMBER FUNCTIONS =======================
void CMainList::ConstructL(const TRect& aRect)
{
CreateWindowL();

// Create the list
CreateListL();

// Observe the list
iListBox->SetListBoxObserver(this);

//Set a Default Message if there is not data.
// iListBox->View()->SetListEmptyTextL(KEmptyText);

// Set up scroll bars
SetupScrollBarsL();

SetRect(aRect);
ActivateL();
}

void CMainList::CreateListL()
{
// First phase construction
iListBox = new (ELeave) CAknSingleStyleListBox;
iListBox->SetContainerWindowL(*this);

// Second Phase Construction
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC(reader, R_MAINLIST_LISTBOX);
iListBox->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader

}

/**
* Creates vertical scrollbars for the list, which appear automatically when required.
*/
void CMainList::SetupScrollBarsL()
{
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
}

CMainList* CMainList::NewL(const TRect& aRect)
{
CMainList* self = CMainList::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}

CMainList* CMainList::NewLC(const TRect& /*aRect*/)
{
CMainList* self = new (ELeave) CMainList;
CleanupStack::PushL(self);
return self;
}

CMainList::~CMainList()
{
delete iListBox;
iListBox = 0;
}

TInt CMainList::GetCurrentItemIndex()
{
return iListBox->CurrentItemIndex();
}

void CMainList::SizeChanged()
{
iListBox->SetExtent(KListPosition, iListBox->MinimumSize());
}

TInt CMainList::CountComponentControls() const
{
return 1; // return number of controls inside this container
}

CCoeControl* CMainList::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iListBox;
default:
return NULL;
}
}

void CMainList::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear(aRect);
}

TKeyResponse CMainList::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (iListBox)
return iListBox->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}

void CMainList::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
// if the Select Key has been pressed
if (aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed)
{
}
}
// End of File





//The CMainListView Code

#include "MainListView.h"
#include "MainList.h"

#include <aknviewappui.h>
#include <smsobserver.rsg>

#include <aknglobalnote.h>


#include "smsobserver.hrh"


CMainListView::~CMainListView()
{
delete iContainer;
iContainer = 0;
}

CMainListView* CMainListView::NewL()
{
CMainListView* self = CMainListView::NewLC();
CleanupStack::Pop(self);
return self;
}

CMainListView* CMainListView::NewLC()
{
CMainListView* self = new (ELeave) CMainListView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}

CMainListView::CMainListView()
{
}

void CMainListView::ConstructL()
{
//construct the menu for this view.
BaseConstructL(R_SMSOBSERVER_MAINLIST);
}

CMainList* CMainListView::Container()
{
return iContainer;
}

TUid CMainListView::Id() const
{
//return the id of this view.
return TUid::Uid(ESmsObserverMainListViewId);
}

void CMainListView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
{
if(!iContainer)
{
iContainer = CMainList::NewL(AppUi()->ClientRect());
iContainer->SetMopParent(this);
iContainer->ConstructL(AppUi()->ClientRect());

AppUi()->AddToStackL(*this, iContainer);
}
}

void CMainListView::DoDeactivate()
{
if(iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
}

void CMainListView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
default:
AppUi()->HandleCommandL(aCommand);
break;
}
}

CSmsObserverAppUi& CMainListView::GetAppUi()
{
CAknViewAppUi* temp = AppUi();
CSmsObserverAppUi* smsobserver = reinterpret_cast<CSmsObserverAppUi*>(temp);
return *smsobserver;
}





//This is the code from the AppUi
void CSmsObserverAppUi::ConstructL()
{
//At this code it panicked
BaseConstructL();

GetMessagesFromInbox();
CreateCDesCArrayFlatL();

iLabelView = CLabelContainerView::NewL();
AddViewL(iLabelView);

iListView = CListContainerView::NewL(iArrayFlat);
AddViewL(iListView);

iMainListView = CMainListView::NewL();
AddViewL(iMainListView);
SetDefaultViewL(*iMainListView);
}

////////////////////////////////////////////////////////////////////
This is the rss file...
NAME HELL

#include <eikon.rh>
#include <eikon.rsg>
#include <avkon.rh>
#include <avkon.rsg>

#include "SmsObserver.hrh"

// ---------------------------------------------------------
//
// Define the resource file signature
// This resource should be empty.
//
// ---------------------------------------------------------
//
RESOURCE RSS_SIGNATURE { }

// ---------------------------------------------------------
//
// Default Document Name
//
// ---------------------------------------------------------
//
RESOURCE TBUF r_default_document_name { buf=""; }


RESOURCE EIK_APP_INFO
{
menubar = r_smsobserver_menubar2;
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}

// ---------------------------------------------------------
// Define Label view
// ---------------------------------------------------------
//
RESOURCE AVKON_VIEW r_smsobserver_label
{
menubar = r_smsobserver_menubar1;
cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
}

// ---------------------------------------------------------
// Define list view
// ---------------------------------------------------------
//
RESOURCE AVKON_VIEW r_smsobserver_List
{
menubar = r_smsobserver_menubar2;//for list
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}

// ---------------------------------------------------------
// Define main list view
// ---------------------------------------------------------
//
RESOURCE AVKON_VIEW r_smsobserver_mainList
{
menubar = r_smsobserver_menubar3;//for main list
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}

// ---------------------------------------------------------
// MenuBar Resource
// ---------------------------------------------------------
//
RESOURCE MENU_BAR r_smsobserver_menubar1
{//for label
titles =
{
MENU_TITLE {menu_pane = r_smsobserver_menu1;}
};
}

RESOURCE MENU_BAR r_smsobserver_menubar2
{//for list
titles =
{
MENU_TITLE {menu_pane = r_smsobserver_menu2;}
};
}

RESOURCE MENU_BAR r_smsobserver_menubar3 //for main list
{//for mainlist
titles =
{
MENU_TITLE {menu_pane = r_smsobserver_menu3;}
};
}
// ---------------------------------------------------------
// ---------------------------------------------------------
// ---------------------------------------------------------
RESOURCE MENU_PANE r_smsobserver_menu1
{//for label
items =
{
MENU_ITEM
{
txt = "Call Number";
command = EContainerCall;
},
MENU_ITEM
{
txt ="Delete Message";
command = ELabelContainerDelete;
}
};
}


RESOURCE MENU_PANE r_smsobserver_menu2
{//for list
items =
{
MENU_ITEM
{
txt = "Call Number";
command = EContainerCall;
},
MENU_ITEM
{
txt = "View Message";
command = EListContainerSelect;
},
MENU_ITEM
{
txt = "Delete Message";
command = EListContainerDelete;
}
};
}

RESOURCE MENU_PANE r_smsobserver_menu3
{//for list
items =
{
MENU_ITEM
{
txt = "Exit";
command = EEikCmdExit;
}
};
}

// ---------------------------------------------------------
//
// The list box
//
// ---------------------------------------------------------
//

RESOURCE LISTBOX r_list_listbox
{
// array_id = r_list_items;
flags = EAknListBoxSelectionList;
}

RESOURCE LISTBOX r_mainlist_listbox
{
array_id = r_list_items;
flags = EAknListBoxSelectionList;
}

RESOURCE ARRAY r_list_items
{
items =
{
LBUF
{
txt = "\tProcess All Messages";
}
};
}

Tue, 2006-03-07 09:23
Joined: 2004-12-23
Forum posts: 239
Re: MultipleView Problem, plz help
Hi

On which IDE you are working.
This panic is realted to allocation and deletion of arrays.
If you are working in Codewarrior then u have to more preventive .Could u post the code of the function which u r using inside the ConstructL() of APPUI.

BR

---------------
Bhatt Kavita

  • Login to reply to this topic.