Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor netra's Avatar
    Join Date
    Dec 2006
    Posts
    94
    Hi,

    I hv a class like this
    XMLData()
    {
    public:

    ~CXMLData();
    static CXMLData* NewL();
    static CXMLData* NewLC();
    private :
    CXMLData();
    void ConstructL();

    private:
    HBufC* elementName;
    RPointerArray<HBufC> attibutesNameValue;
    HBufC* contents;

    }


    Then I have created an array of objects of XMLData as follows:

    I declared an array as the member of XMLHandler class.

    RPointerArray<CXMLData> elementArray;

    On CXmlHandler::OnStartElementL( const RTagInfo& aElement,
    const RAttributeArray& aAttributes, TInt aErrorCode ) I am going to store
    the element name value in the elementName member.The code(half written) is as follows that gives me
    KERN EXEC 3 Panic.

    Pls help me in resolving the panic and in storing the element name in elemntName varibale.(I am being confused in using descrioptors properly here )

    <code>void CXmlHandler::OnStartElementL( const RTagInfo& aElement,
    const RAttributeArray& aAttributes, TInt aErrorCode )
    {


    if ( KErrNone == aErrorCode )
    {
    // If we find the start of an element, we write to the screen,
    // for example: "<tag>"
    AppendTag( aElement.LocalName().DesC(), EFalse );

    // assign the element name to the element object
    CXMLData* xmlElement= CXMLData::NewLC();
    TBuf8<15> name=aElement.LocalName().DesC();
    //HBufC* name16 = Copy8To16L(name);
    CAknInformationNote* aiNote = new (ELeave)CAknInformationNote;
    aiNote->ExecuteLD(_L("OK UPTO HERE "));


    //xmlElement->elementName->Copy(name16,name.Length());
    TPtr ptr(xmlElement->elementName->Des());
    ptr.Copy(name);




    TInt count = aAttributes.Count();
    for(TInt i=0; i<count; i++)
    {
    TBuf8<20> name = aAttributes[i].Attribute().LocalName().DesC();
    HBufC *buf=HBufC::NewLC(name.Length());
    buf->Des().Copy(name);


    /*TBuf8<100> value= aAttributes[i].Value().DesC();
    HBufC *bufVal=HBufC::NewLC(value.Length());
    bufVal->Des().Copy(value);*/

    TBuf8<10> code(_L8("Code"));

    if(code==name)
    {

    CAknInformationNote* iNote = new (ELeave)CAknInformationNote;
    iNote->ExecuteLD(*buf);

    }

    CleanupStack::PopAndDestroy(); // buf

    }


    //Add the parsed element object to the array of elements
    elementArray.AppendL(xmlElement);
    }
    else
    {
    iObserver.OnParseCompleted( aErrorCode );
    }
    }</code>

    Thanks,
    --Netra
    --------------------------------------------------------------
    To know what-to-do is more important than to know how-to-do !
    --------------------------------------------------------------

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Do not hesitate using a debugger, and fixing asymmetric usage of Cleanup Stack.

  3. #3
    Regular Contributor sashaslonmailer's Avatar
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56
    hi,

    may be you have out of range in arrays

  4. #4
    Regular Contributor netra's Avatar
    Join Date
    Dec 2006
    Posts
    94
    Hi,

    If we allocate memory on heap and the pointer to it is an automatic variable then it should be pushed to the cleanupstack.That is what I am doing in the following code but its giving error:

    HTML Code:
    1>..\src\XmlHandler.cpp(263) : error: function call '[CXmlHandler].PushL({lval} TPtr16)' does not match
    1>'CleanupStack::PushL(void *)' (static)
    1>'CleanupStack::PushL(CBase *)' (static)
    1>'CleanupStack::PushL(TCleanupItem)' (static)
    1>Errors caused tool to abort.
    Where am I going wrong ?
    Thanking U,
    NN
    --------------------------------------------------------------
    To know what-to-do is more important than to know how-to-do !
    --------------------------------------------------------------

  5. #5
    Registered User laa-laa's Avatar
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    You should never not store automatic variables to cleanup stack. If you allocate an HBufC heap buffer, then the pointer to it is an HBufC*, not a TPtr. You can push the HBufC* on the cleanup stack (or have HBufC do it for you with one of the *LC() factory function variants).

    To the original issue: where is xmlElement->elementName allocated? On a quick glance I did not see it anywhere and calling Des() on an unallocated object is an easy way to KERN-EXEC 3.

    Lauri

Similar Threads

  1. Combining the data in an Array
    By dee_viz in forum Symbian C++
    Replies: 2
    Last Post: 2007-09-17, 14:37
  2. Replies: 6
    Last Post: 2007-03-23, 12:36
  3. PANIC EXEC 3 while including CAknEnumeratedTextPopupSettingItem into a form
    By anand_zain76 in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-05-15, 10:10
  4. PANIC EXEC 3 while using a popup field into selection list mode.
    By anand_zain76 in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-05-15, 09:30
  5. audio data array
    By miranda2112 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2005-08-09, 07:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved