What is wrong here [A data abort exception has occurred]
-
hi everyone!
did I do something wrong here?
!http://files.myopera.com/tratstil/files/nokiaqt.png! -
Was the fileName null terminated? (The last character to be '\0')
Also why do you want to do that operation by that way since there are plenty of easier ways by using QString methods. Just asking..not judging.
-
The filename is an element of an array of char like this
@char* _ResourceFileName[] = {
"tester",
"ten"};
filename = _ResourceFileName[1];@
_ResourceFileName is static.At you see above, if filename is not end with '\0', the line "qDebug()<<"checkpoint1"<<filename" can't work correctly.
And I must using char for some reason.
Thanks for replying favoritas37.
-
If you step through this one line at a time in the debugger, does realname get set correctly?
-
thanks Chris H, it is interesting to try.
I change my code to
@extern "C" const char* GetRealFilePath(const char* filename){
char realname[1024];
qDebug()<<"checkpoint1:"<<filename;
sprintf(realname,"%s",filename);
qDebug()<<"checkpoint2";
qDebug()<<"realname"<<realname;
return NULL;
}@
and get
@[Qt Message] start QtGame
[Qt Message] application event: 68
[Qt Message] \private%s\res\bin%s
[Qt Message] \private\E57BFD88\res\bin%s
[Qt Message] game init
[Qt Message] runhere2: ten
Process 2357, thread 2358 stopped at 0x504b46: A data abort exception has occurred.
*[Qt Message] checkpoint1: ten
[Qt Message] checkpoint2 *
[Qt Message] realname ten @
the realname is correct. But I don't know what happened. The error message above the checkpoint1, is it mean the bug is in another unsynchronize thread?I change the code to
@extern "C" const char* GetRealFilePath(const char* filename){
qDebug()<<"begin function";
char realname[1024];
qDebug()<<"checkpoint1:"<<filename;
sprintf(realname,"%s",filename);
qDebug()<<"checkpoint2";
qDebug()<<"realname"<<realname;
return NULL;
}@
and receive
@[Qt Message] game init
[Qt Message] runhere2: ten
[Qt Message] begin function
Process 2389, thread 2390 stopped at 0x504cda: A data abort exception has occurred.
[Qt Message] checkpoint1: ten
[Qt Message] checkpoint2
[Qt Message] realname ten
[Qt Message] @ -
bq. is it mean the bug is in another unsynchronize thread?
Yeah, that's the only thing that makes any sense here: I'd suggest running in a debugger that will let you see what thread is crashing, and what it's trying to do. I don't trust char * and friends in the least, but they may be totally unrelated to the problem here.
-
hum, more thing to do. You are right. I just return NULL without any code and get the same error message. It means this function not relative at all :D. Thanks you