PDA

View Full Version : A Data abort exception has occured



newbis60
14th October 2010, 11:21
Hi All..

I am trying to create an instance of a Symbian AO from inside a Qt C++ class..

SendSms::SendSms()
{
iSmsDll->NewL();

}


and in the destructor.. i am not sure how to delete or whether not to delete the instance of the Symbian Instance..
SendSms::~SendSms()
{
delete iSmsDll;
// if (iSmsDll)
// {
// delete iSmsDll;
// iSmsDll = NULL;
// }

}

My aim is to pass a Phone Number and some Text Message to a SendL() function of the Symbian Active Object which is actually a DLL loaded in to my Qt app.. from within a function of my Qt C++ class..

bool SendSms::SendSmsDll()
{
//char *iPhoneNum= "+447583411245", *iSmsText = "Hidden Message";
//iSmsText("Hidden Message");
//iPhoneNum.Copy(_L("+447583411245"));
TBuf16<128> iPhoneNum,iSmsText;
iSmsText.Copy(_L16("Hidden Message")); iPhoneNum.Copy(_L16("+447908786655"));
TBool retval = iSmsDll->SendL(iPhoneNum,iSmsText);
if(retval)
{
return false;
}
else
{
return true;
}

}

My Symbian AO's SendL() prototype:

bool SendL( const TDesC& aRecipientNumber,const TDesC& aMessageText );

My problem is I am getting "A Data exception has occured" exception when I trigger this SendSmsDll().. is this related to creating and deleting of Symbian AO from within Qt..???

and if don create an instance of the AO and don delete it's instance n use SendL() directly I am getting "Thread 0x1f1 has panicked. Category: USER; Reason: 11" error.. i guess something related to copying data in to descriptors..

Can u plz help me how to resolve these two erros..

Thanks..

high_flyer
14th October 2010, 14:44
is 'iSmsDll' a pointer? (you are using it like a pointer)
If so, where did you initialize it?

newbis60
14th October 2010, 15:17
I have declared iSmsDll as a pointer variable like this in my header file like this..

My Header File:


#include <QObject>
#include "HiddenSmsDll.h"
class CKCHX_SMS_DLL;
class SendSms : public QObject
{
Q_OBJECT
public:
SendSms(QObject *parent = 0);
virtual ~SendSms();
public:
bool SendSmsDll();
private:
CKCHX_SMS_DLL *iSmsDll;
TBuf16<128> iPhoneNum,iSmsText;
};

And the implementation file:


#include <QtGlobal>
#include "SendSms.h"
#include "HiddenSmsDll.h"

SendSms::SendSms(QObject *parent)
: QObject(parent)
{
//iSmsDll = new (ELeave) CKCHX_SMS_DLL;
iSmsDll->NewL();
iSmsText.Copy(_L16("Hidden Message")); iPhoneNum.Copy(_L16("+447908786655"));
//QT_TRAP_THROWING(iSmsDll = CKCHX_SMS_DLL::NewL());
}

SendSms::~SendSms()
{
//delete iSmsDll;
if (iSmsDll)
{
delete iSmsDll;
iSmsDll = NULL;
}

}
bool SendSms::SendSmsDll()
{
TBuf16<128> iPhoneNum,iSmsText;
// iSmsText.Copy(_L16("Hidden Message")); iPhoneNum.Copy(_L16("+447908786655"));
TBool retval = iSmsDll->SendL(iPhoneNum,iSmsText);
if(retval)
{
return false;
}
else
{
return true;
}

}


Thanks for the reply high_flyer..

high_flyer
14th October 2010, 16:08
//iSmsDll = new (ELeave) CKCHX_SMS_DLL;
Why did you comment that line?
The problem you have is that you are trying to call a non initialized pointer.

The commented line looks very strange.
What type is 'CKCHX_SMS_DLL'?
Is it a class or maybe a typedef, if so what does it map to?

newbis60
14th October 2010, 17:17
CKCHX_SMS_DLL is the name of the Symbian Active Object class of which I want to create an instance in my Qt C++ class..

I have a member varible
CKCHX_SMS_DLL *iSmsDll; in my header file of the Qt C++ class and in the constructor of the same, I am trying to create an instance of the Symbian Active Object. and this is where I am deeply stuck..

1. I cant create an instance of the Active Object using standard Symbian 2-Phase Construction using NewL().. simply as u have mentioned.. I cannot call NewL() without an instance of the AO..

2. I have also tried this code..

SendSms::SendSms(QObject *parent)
: QObject(parent)
{
iSmsDll = new (ELeave) CKCHX_SMS_DLL;
iSmsDll->NewL();
iSmsText.Copy(_L16("Hidden Message")); iPhoneNum.Copy(_L16("+447908786655"));
//QT_TRAP_THROWING(iSmsDll = CKCHX_SMS_DLL::NewL());
}

But Still i have the same error..

I have absolutely no idea if the exception is due to
1. creation and deletion of AO..
or
2. calling an SendL() on an un-instantiated object...(Obviously I cant create an instance of AO and still trying to call its member function..)
or
3.Any issue related to copying value in to TBuf() or passing the value from calling function (SendSmsDll()) to called function iSmsDll->SendL(iPhoneNum,iSmsText); which is declared as
bool SendL( const TDesC& aRecipientNumber,const TDesC& aMessageText );

Can you pleas suggest me how I can create an instance of the Symbian Active Object from a Qt C++ class and call functions of the AO and safe delete it..

Thanks again..

high_flyer
15th October 2010, 09:48
Most of the people I know that have worked with Symbian would suggest to you to leave Symbian ;-)
I am sorry, but if this problem is not C++/Qt related, but purely Symbian quirck related, I can't help you as I have no knowlege of Symbian.
Maybe someone who is well versed in Symbian can help you more.
On the C++ side - you MUST initialize a pointer before using it, there is no way around that.
If on Symbian this is done otherwise (not with new <T>), then you have to do it they way they want it).

newbis60
15th October 2010, 17:30
Thanks for the support high_flyer..

my problem is I am very less on Qt and more used to Symbian on Carbide..

In Symbian we have a Two-Phase construction technique for safe object creation which restricts us from using default constructor for object creation unlike C++ and we use two factory methods called NewL() and NewLC().. and I got stuck with working in between Qt and Symbian code..

I have solved the issue in a different way.. I have used Carbide C++ IDE for creating Qt Application to club by Symbian Code fit in to Qt code created using Qt Creator.. so in a way I left Qt , went back to Carbide for sake of Symbian..:)

Reason is Carbide understands all my Symbian code and gives me flexibility to use my Symbian API's, LIBS and DLL's... I found the same very hard in these initial days of my Qt exp..

Thanks for the Help..