Descriptor array problem

Login to reply to this topic.
Mon, 2008-02-11 09:54
Joined: 2005-01-25
Forum posts: 32

Dear All,

I am struggling with Symbian arrays. I am trying to use CDesC8Array-s. I allocated two of them on the heap, added some elements to it but I get a Kern-Exec 3 panic when I try to access their size.

(BTW it seems also not to work if I keep things on the stack)

Is there something obviously wrong with the following code?

        CDesC8Array * paramNames  = new (ELeave) CDesC8ArrayFlat(4);
        CleanupStack::PushL( paramNames );
        CDesC8Array * paramValues = new (ELeave) CDesC8ArrayFlat(4);
        CleanupStack::PushL( paramValues );
       
        paramNames->AppendL( _L8("name1") );
        paramValues->AppendL( _L8("value1") );
       
        paramNames->AppendL( _L8("name2") );
        paramValues->AppendL( _L8("value1") );
       
        paramNames->AppendL( _L8("name3") );
        paramValues->AppendL( _L8("value3") );
       
        paramNames->AppendL( _L8("name4") );
        paramValues->AppendL( _L8("value4") );

        TInt valuesCount = paramValues->MdcaCount();
        TInt namesCount = paramNames->MdcaCount();

        [...]

Is there any good reference for arrays on line?

Thanks,
Enrico


Mon, 2008-02-11 10:10
Joined: 2005-11-20
Forum posts: 1241
Re: Descriptor array problem

I never used MdcaCount(), I always used Count(), and it worked.

I did not understand from the SDK documentation what MdcaCount() should be good for, so I don't know whether that's really the problem or not.


René Brunner

Mon, 2008-02-11 10:45
Joined: 2005-01-25
Forum posts: 32
Re: Descriptor array problem

Thanks for your reply.

I tried changing MdcaCount() for Count() but it's the very same. I guess one probably calls the other.

Any other pointers or suggestions?

Thanks,
Enrico

Mon, 2008-02-11 12:38
Joined: 2005-01-25
Forum posts: 32
Re: Descriptor array problem

Hello again.

I changed the code to try and use RArray, but I still get weird behaviour from Count(), in this case the application does not crash but I get rubbish values:

RArray<TPtrC8> paramNamesInst(4);
CleanupClosePushL( paramNamesInst );
RArray<TPtrC8> paramValuesInst(4);
CleanupClosePushL( paramValuesInst );

paramNamesInst.AppendL( _L8("name1") );
paramValuesInst.AppendL( _L8("value1") );
       
paramNamesInst.AppendL( _L8("name2") );
paramValuesInst.AppendL( _L8("value1") );
               
paramNamesInst.AppendL( _L8("name3") );
paramValuesInst.AppendL( _L8("value3") );
               
paramNamesInst.AppendL( _L8("name4") );
paramValuesInst.AppendL( _L8("value4") );
       
// the following 2 return rubbish
TInt valuesCount = paramValuesInst.Count();
TInt namesCount = paramNamesInst.Count();

paramNamesInst.Close();
paramValuesInst.Close();
CleanupStack::Pop(2)

Any ideas what may be causing this?

Thanks,
Enrico

Mon, 2008-02-11 13:21
Joined: 2004-12-07
Forum posts: 72
Re: Descriptor array problem

If you get the panic: Kern-Exec 3, it seems that paramNames is NULL. Maybe you can debug it.

Tue, 2008-02-12 05:06
Joined: 2007-09-03
Forum posts: 25
Re: Descriptor array problem

The latest code that you have posted is giving perfect results. 'valuesCount' is being assigned 4 and 'namesCount' is also being assigned with 4. Are you still having the problem?

Tue, 2008-02-12 08:14
Joined: 2005-01-25
Forum posts: 32
Re: Descriptor array problem

Thanks aniait.

I realized that the problem was not in the array but in the method I use for logging its size Sad
..which in turn had to do (I think) with the va_list macro having slightly changed behavior in the latest Symbian release.

Enrico

Tue, 2008-02-12 08:30
Joined: 2005-11-20
Forum posts: 1241
Re: Descriptor array problem

In such cases of mystery I use the debugger with the emulator whenever possible, and it's only impossible if the phone shows the mystery but not the emulator, which is quite rare. In your case I would have been able to directly look at the value of the 'valuesCount' variable in the debugger.

That's why I keep telling everybody who listens and everybody else anyway: Don't do Symbian programming without a debugger. You will get unhappy otherwise.


René Brunner

Tue, 2008-10-14 13:57
Joined: 2008-10-14
Forum posts: 1
Re: Descriptor array problem

I tried to use FleaC classes (FString, FStringList, etc.) for descriptors and arrays, and find it quite easy way to avoid traditional Symbian way. Not sure, if there is a device (urel) version available, but at least in the emulator it works fine! FleaC documentation is in my bookmarks: http://www.fleasome.com/index.php/the-project/documentation

  • Login to reply to this topic.