MTextListBoxModel implementation problems.
| Mon, 2005-03-28 11:26 | |
|
Hi. I have problems impelementing MTextListBoxModel model in my application.
The implementation works on the simulator, but not on the device. Here is a sample implementation: _LIT(T,"TEST"); int CListBoxModel::NumberOfItems() const { return 6; } const MDesCArray* CListBoxModel::MatchableTextArray() const { return 0; } TPtrC CListBoxModel::ItemText(TInt aItemIndex) const { return TPtrC(T); } This works perfectly on the simulator, but crashes on the device. Any suggestions? |
|






Forum posts: 982
And where exactly crashes on the device?
pirosl
Forum posts: 11
TPtrC CListBoxModel::ItemText(TInt aItemIndex) const
{
return TPtrC(T);
}
I've tried different kidn of things
HBuf, TBuf, allocating on the heap, etc.
the result is the same, so i post the simplest form.
This crashes on several devices, that I have tested.
Forum posts: 982
TPtrC CListBoxModel::ItemText(TInt aItemIndex) const
{
_LIT(KText,"My List Model");
TBufC<16> buf1(KText);
return TPtrC(buf1);
}
pirosl
Forum posts: 11
{
_LIT(KText,"My List Model");
TBufC<16> buf1(KText);
return TPtrC(KText);
}
This Returns My List Model in the ListBox on the simulator
TPtrC CListBoxModel::ItemText(TInt aItemIndex) const
{
_LIT(KText,"My List Model");
TBufC<16> buf1(KText);
return TPtrC(buf1);
}
This returns nonsense in the listitems of the listbox on the simulator
as if it displays uninitialized data
Forum posts: 982
So simply do
TPtrC CListBoxModel::ItemText(TInt aItemIndex) const
{
_LIT(KText,"My List Model");
return TPtrC(KText);
}
This should work.
pirosl
Forum posts: 11
That's why I posted this.
If you wish, i can post here the whole infrastructure setup of the listbox, etc..
If you have a phone to try it. I have nokia 6630 and i cannot setup gdb on it, because they have no com server installed on it.
I cannot explain why is this? Very, very strange
Forum posts: 982
That's why I posted this.
If you wish, i can post here the whole infrastructure setup of the listbox, etc..
If you have a phone to try it. I have nokia 6630 and i cannot setup gdb on it, because they have no com server installed on it.
I cannot explain why is this? Very, very strange
I have a nokia 3660. Can you send me the package by email?
pirosl
Forum posts: 11
Forum posts: 982
pirosl
Forum posts: 11
Forum posts: 11
Unfortunately the problem is not yet resolved
The sample imeplementation works on 3660. Also I've managed to test it on Nokia 7650. It works there two.
On Nokia 6630 it crashes, it also crashes on Nokia 6670
I've managed to locate the problem. The problem is in the Drawer
not in the ListBoxModel.
I will post some code later for the people in this forum.
Forum posts: 11
if anyone is interested
Typically when one subclasses a listbox a drawer is used too.
drawer=new (ELeave) CTextListItemDrawer(model,CEikonEnv::Static()->NormalFont());
CleanupStack::PushL(drawer);
drawer->ConstructL(CEikonEnv::Static()->NormalFont());
CleanupStack::Pop();
so, the bug in the implementation of CTextListItemDrawer
in the function DoDrawItemText this is where s60 nokia 6630, 6670 and other models crash (the simulator for 7.0s crashes too). This does not crash on the older models
but if you write:
drawer=new (ELeave) CTextListItemDrawer(model,CEikonEnv::Static()->NormalFont());
then everything is ok on the new models.
Generally the problem is in the intefaces and most of all poor, poor documentation and lack of good examples.
for example only series 60 1.2 has CTextListItemDrawer if you search in the help file
Forum posts: 47
I ask because I fail to implement my own listbox model and associate it with the listbox.
What I do is this: I derive my own listbox class form CAknDoubleStyleListBox (that's the style I want) and override the ContructL. At the ConstructL I create my own model and give it to CEikListBox::ConstructL(model, drawer...). As I result I see that the listbox internal structure has a whole different address for iModel and of course getting the model with Model() does give a whole a different object. And to mention - none of my overridden model function are called.
Any help appreciated.
tnx in advance
Ahti.
Forum posts: 47
That's the advice to the original poster as well - instead of reimplementing model (which I personally failed big times), add MDesCArray to your data class and provide two simple methods: MdcaCount and MdcaPoint.
Easy as abc.
Ahti.