KERN EXEC 3 panic + array of descriptor issue in storing data on OnStartElement
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
Re: KERN EXEC 3 panic + array of descriptor issue in storing data on OnStartElement
Do not hesitate using a debugger, and fixing asymmetric usage of Cleanup Stack.
Re: KERN EXEC 3 panic + array of descriptor issue in storing data on OnStartElement
hi,
may be you have out of range in arrays
Re: KERN EXEC 3 panic + array of descriptor issue in storing data on OnStartElement
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]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.[/HTML]
Where am I going wrong ?
Thanking U,
NN
Re: KERN EXEC 3 panic + array of descriptor issue in storing data on OnStartElement
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