Results 1 to 19 of 19

Thread: Program not running exited with code 0

  1. #1
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Program not running exited with code 0

    while running my qt code

    Running build steps for project qbank...
    Configuration unchanged, skipping QMake step.
    Starting: /usr/bin/make debug -w
    make: Entering directory `/home/tts/Desktop/QbankEditorAllrequirement'
    /usr/bin/make -f Makefile.Debug
    make[1]: Entering directory `/home/tts/Desktop/QbankEditorAllrequirement'
    make[1]: Nothing to be done for `first'.
    make[1]: Leaving directory `/home/tts/Desktop/QbankEditorAllrequirement'
    make: Leaving directory `/home/tts/Desktop/QbankEditorAllrequirement'
    Exited with code 0.

    i'm working in qt4.

    Running build steps for project qbank...
    Configuration unchanged, skipping QMake step.
    Starting: /usr/bin/make debug -w
    make: Entering directory `/home/tts/Desktop/QbankEditorAllrequirement'
    /usr/bin/make -f Makefile.Debug
    make[1]: Entering directory `/home/tts/Desktop/QbankEditorAllrequirement'
    make[1]: Nothing to be done for `first'.
    make[1]: Leaving directory `/home/tts/Desktop/QbankEditorAllrequirement'
    make: Leaving directory `/home/tts/Desktop/QbankEditorAllrequirement'
    Exited with code 0.

    while commiting to db i get the exit status as,

    ASSERT: "i >= 0" in file /usr/include/qt4/QtCore/qstring.h, line 875
    The program has unexpectedly finished.
    /home/tts/Desktop/QbankEditorAllrequirement/qbank exited with code 0

    when i debug my code

    "The inferior stopped because it received a signal from the Operating system
    Signal name : SIGABRT
    Signal meaning : SignalAborting"

    when i click ok,
    it shows the error in my commit.cpp file,
    in while loop.
    any1 knows wat the error might be.please help me

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Program not running exited with code 0

    There may be an error in commit.cpp, check the call stack
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    gayathrisekaran (8th November 2012)

  4. #3
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    But the same code finely runs in qt3. will you please explain what is call stack.
    thanks for your reply


    Added after 5 minutes:


    But the same code finely runs in qt3. will you please explain what is call stack.
    thanks for your reply
    Last edited by gayathrisekaran; 8th November 2012 at 05:20.

  5. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Program not running exited with code 0

    Refer this CallStack.jpg
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. The following user says thank you to Santosh Reddy for this useful post:

    gayathrisekaran (8th November 2012)

  7. #5
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    Sorry, may be my question is a silly thing, but i am a beginner in both qt and c++ so please tell me weather in my code also it seems the same or not

    Actually my code is


    case SHORT:
    /*write the parsing stuff ..... for parsing the options member of the object to seperate the statement and
    main phrase parts*/
    Ques=((Short *)object)->stmt[0];
    Question=parseQuestion(Ques); // function called for replacing tilde,cape symbol to angluar brackets
    Questemp=Question;
    ((Short *)object)->stmt[0]=Questemp;
    temp = "\"" + chapter + "\", \"" + board + "\", \"" + subject + "\", \"" + temp2.setNum(((baseFillChoose *)object)->pageNo)+ "\", \"" + ((Short *)object)->Queswav + "\",";
    temp += " \"" + ((Short *)object)->stmt[0] + "\",\"" + ((Short *)object)->mgif[0] + "\",\"" + ((Short *)object)->mgif1[0] + "\", \"" + ((Short *)object)->ChooseType + "\", \"" +((Short *)object)->misc[0] + "\"";
    text12="insert into ShortQues(Chapter,Board,Subject,PageNo,Queswav,Que stion,Q1Gif1,Q1Gif2,Shorttype,StaticGif1) values (" + temp + ");";
    cout<<"text12\n"<<text12<<endl;
    query = new QSqlQuery("insert into ShortQues(Chapter,Board,Subject,PageNo,Queswav,Que stion,Q1Gif1,Q1Gif2,Shorttype,StaticGif1) values (" + temp + ")");
    temp = "";
    index = 0;
    query = new QSqlQuery("select MAX(QNo) as QNo from ShortQues");
    if(!query->first())
    {
    exit(-2);
    }
    qNo = (query->value(0)).toInt();

    for(i = 0;i<object->getNumOpt();i++)
    {
    index = 0;
    while((((Short *)object)->options[i])[index]!='\0') //here it points
    {
    index = parseOption(index,((Short *)object)->options[i],stmt1,phrase);
    cout<<"index : "<<index<<"\n"<<stmt1<<"\n"<<phrase<<endl;
    QString text11;
    stmt1temp=stmt1;
    cout<<"stmt1temp\n"<<stmt1temp<<endl;
    stmt1=stmt1temp;
    cout<<"stmt1\n"<<stmt1<<endl;
    phrasetemp=phrase;
    cout<<"phrasetemp\n"<<phrasetemp<<endl;
    phrase=phrasetemp;
    cout<<"phrase\n"<<phrase<<endl;
    if(index!=-1)
    {

    text11="insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo ,CorrectNo) values (\"" + stmt1 + "\", NULL,\"" + phrase + "\"," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1]) + ",1)";
    cout<<"\n\ntext11"<<text11<<endl;

    query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo ,CorrectNo) values (\"" + stmt1 + "\", NULL,\"" + phrase + "\"," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1])+",1)");
    }
    else {
    query = new QSqlQuery("select MAX(APNo) as APNo from ShAnsPts where QNo=" + temp2.setNum(qNo) +"&& PointNo=" + temp2.setNum(((Short *)object)->ptno[i+1]));

    if(!query->first())
    {
    cout<<"There is no main phrase in this point ..... aborting\n";
    exit(-2);
    }
    aPNo = (query->value(0)).toInt();
    cout<<"This is apNo values"<<aPNo<<endl;
    stmt1=parseQuestion(stmt1); // function called for replacing tilde,cape symbol to angluar brackets
    stmt2temp=parseStepNo(stmt1,i,aPNo);
    cout<<"\nThis is the apno value required"<<aPNo<<endl;
    // stmt2temp=stmt1;
    stmt2=stmt2temp;
    cout<<"This is STatement2 value"<<stmt2<<endl;
    // (((baseFillChoose *)object)->stepno[i+1])=stepval[i];
    // cout<<"This is stepmark value"<<stepval[i]<<endl;
    query = new QSqlQuery("update ShAnsPts set Statement2 = \"" + stmt2 + "\" where APNo=" + temp2.setNum(aPNo));
    // query = new QSqlQuery("update ShAnsPts set StepMark = \"" + ((baseFillChoose *)object)->stepno[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    query = new QSqlQuery("update ShAnsPts set Q1Gif1 = \"" + ((Short *)object)->mgif[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    query = new QSqlQuery("update ShAnsPts set Q1Gif2 = \"" + ((Short *)object)->mgif1[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    query = new QSqlQuery("update ShAnsPts set StaticGif1 = \"" + ((Short *)object)->misc[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    query = new QSqlQuery("update ShAnsPts set voiceover = \"" + ((Short *)object)->voiceovers[i+1] + "\" where APNo=" + temp2.setNum(aPNo));

    }
    }
    }

    break;

    After entering into the following code

    int mainForm:arseOption(int ind,QString option, QString &stmt1, QString &phrase)
    {
    QTextStream cout(stdout, QIODevice::WriteOnly);
    int j = 0;
    int index = ind;
    cout<<"311 : parseOption : "<<option<<endl;
    cout<<"index&&\n"<<index<<endl;
    while(option[index] != '|')
    {
    stmt1[j] = option[index];
    cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    if(option[index]=='\0')
    {
    stmt1[j] = '\0';
    cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    option[0] = '\0';
    cout<<"option[0]\n"<<option[0]<<endl;
    return -1;
    }
    index++;
    j++;
    }
    stmt1[j] = '\0';
    cout<<"stmt1[j]**&\n"<<stmt1[j]<<endl;
    stmt1=stmt1.replace( "{sub}","<sub>");
    stmt1=stmt1.replace( "{/sub}","</sub>" );

    cout<<"425 : "<<stmt1<<endl;
    j = 0;
    index++;
    while(option[index] != '\\')
    {
    phrase[j] = option[index];
    index++;
    j++;
    }
    phrase=phrase.replace( "{sub}","<sub>" );
    phrase=phrase.replace( "{sub}","<sub>" );
    cout<<"Phrase value"<<phrase<<endl;
    phrase[j] = '\0';
    cout<<"436 : "<<phrase<<endl;

    return (index + 1);

    }

    then return to the above while condition

    it exit and showing
    ASSERT: "i >= 0" in file /usr/include/qt4/QtCore/qstring.h, line 875
    The program has unexpectedly finished.
    /home/tts/Desktop/QbankEditorAllrequirement/qbank exited with code 0
    Last edited by gayathrisekaran; 8th November 2012 at 08:35. Reason: updated contents

  8. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Program not running exited with code 0

    Qt Code:
    1. int mainForm:arseOption(int ind,QString option, QString &stmt1, QString &phrase)
    2. {
    3. ...
    4. while(option[index] != '|') //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    5. {
    6. stmt1[j] = option[index]; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    7. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;//<<<<<<<<<<<<<<<<<<<<<
    8. if(option[index]=='\0')//<<<<<<<<<<<<<<<<<<<<<
    9. {
    10. stmt1[j] = '\0';
    11. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;//<<<<<<<<<<<<<<<<<<<<<
    12. option[0] = '\0';
    13. cout<<"option[0]\n"<<option[0]<<endl;//<<<<<<<<<<<<<<<<<<<<<
    14. return -1;
    15. }
    16. index++;
    17. j++;
    18. }
    19. ...
    20. }
    To copy to clipboard, switch view to plain text mode 
    Refer the comments in code, you are using operator []. What do you think will happen if use stmt[i] or option[index] when stmt and option are empty strings?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  9. The following user says thank you to Santosh Reddy for this useful post:

    gayathrisekaran (8th November 2012)

  10. #7
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    The '|' operator is used, when entering the options.
    To highlight the important phrase in the answers '|' operator is used.


    Added after 18 minutes:


    Through editor, i am entering the question and answers.
    After entering the question and answers,it then comes to "parse" functions.
    Then how will it take the stmt and option as empty string.
    Its just to check, if stmt and options are empty then it should print empty,otherwise it should have to execute the query.
    Bt i've given both question and answers, then hw it seems to be empty.


    Added after 1:


    Through the editor i am entering the question in the database.But for entering shortquestions and Longquestions while "entering the questions" it enter into the "parseQuestion" function and enter the query into the database.
    Also in "parseOption" function it is parsing the question itself and not the answers and none is updated in the database (i.e in queston table the question is entering. bt in answer table nothing get entered).
    showing the table empty.
    In that code, some conditions are checked for entering the options.
    In the "parseOption" function the options is to be parsed. But for me the question itself is getting parsed.
    Eventhough i enter the option in that format, and when i clicked commit to db i still get exit from my editor returning that status.

    ASSERT: "i >= 0" in file /usr/include/qt4/QtCore/qstring.h, line 875
    The program has unexpectedly finished.
    /home/tts/Desktop/QbankEditorAllrequirement/qbank exited with code 0

    will you please tell me why it is taking like tat.
    Last edited by gayathrisekaran; 8th November 2012 at 11:42. Reason: spelling corrections

  11. #8
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    Sometimes it get entered to db and sometimes not.Will u please tell me wat the problem is?


    Added after 28 minutes:


    while entering the Ques it get parsed in the following code

    QString mainForm:arseQuestion(QString &stmt1)
    {
    QTextStream cout(stdout, QIODevice::WriteOnly);
    cout<<"It is coming inside the parse function"<<endl;
    stmt1=stmt1.replace( QChar('^'),QChar('<') );
    stmt1=stmt1.replace( QChar('~'),QChar('>') );
    stmt1=stmt1.replace( "{sub}","<sub>" );
    stmt1=stmt1.replace( "{/sub}","</sub>" );
    stmt1=stmt1.replace( "{sup}","<sup>" );
    stmt1=stmt1.replace( "{/sup}","</sup>" );
    return(stmt1);
    }

    And when the options get entered it is nt parsing in the "parseOption" function.
    The "parseOption" function also parses the Ques itself, and tat Ques is taken as the stmt value one by one and finally printing as the stmt as[].
    The option isprinting as []. Y its taking lik tis pls tell me
    Last edited by gayathrisekaran; 8th November 2012 at 13:01. Reason: updated contents

  12. #9
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Program not running exited with code 0

    First use tags to post your code, nobody will be interested to look at your code if it is not readable quickly, (eg. [CODE]....[ /CODE])
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  13. #10
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    sorry

    Qt Code:
    1. case SHORT:
    2. /*write the parsing stuff ..... for parsing the options member of the object to seperate the statement and
    3. main phrase parts*/
    4. Ques=((Short *)object)->stmt[0];
    5. Question=parseQuestion(Ques); // function called for replacing tilde,cape symbol to angluar brackets
    6. Questemp=Question;
    7. ((Short *)object)->stmt[0]=Questemp;
    8. temp = "\"" + chapter + "\", \"" + board + "\", \"" + subject + "\", \"" + temp2.setNum(((baseFillChoose *)object)->pageNo)+ "\", \"" + ((Short *)object)->Queswav + "\",";
    9. temp += " \"" + ((Short *)object)->stmt[0] + "\",\"" + ((Short *)object)->mgif[0] + "\",\"" + ((Short *)object)->mgif1[0] + "\", \"" + ((Short *)object)->ChooseType + "\", \"" +((Short *)object)->misc[0] + "\"";
    10. text12="insert into ShortQues(Chapter,Board,Subject,PageNo,Queswav,Que stion,Q1Gif1,Q1Gif2,Shorttype,StaticGif1) values (" + temp + ");";
    11. cout<<"text12\n"<<text12<<endl;
    12. query = new QSqlQuery("insert into ShortQues(Chapter,Board,Subject,PageNo,Queswav,Que stion,Q1Gif1,Q1Gif2,Shorttype,StaticGif1) values (" + temp + ")");
    13. temp = "";
    14. index = 0;
    15. query = new QSqlQuery("select MAX(QNo) as QNo from ShortQues");
    16. if(!query->first())
    17. {
    18. exit(-2);
    19. }
    20. qNo = (query->value(0)).toInt();
    21.  
    22. for(i = 0;i<object->getNumOpt();i++)
    23. {
    24. index = 0;
    25. while((((Short *)object)->options[i])[index]!='\0') //here it points
    26. {
    27. index = parseOption(index,((Short *)object)->options[i],stmt1,phrase);
    28. cout<<"index : "<<index<<"\n"<<stmt1<<"\n"<<phrase<<endl;
    29. QString text11;
    30. stmt1temp=stmt1;
    31. stmt1=stmt1temp;
    32. phrasetemp=phrase;
    33. phrase=phrasetemp;
    34. if(index!=-1)
    35. {
    36.  
    37. text11="insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo ,CorrectNo) values (\"" + stmt1 + "\", NULL,\"" + phrase + "\"," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1]) + ",1)";
    38. cout<<"\n\ntext11"<<text11<<endl;
    39.  
    40. query = new QSqlQuery("insert into ShAnsPts(Statement1,Statement2,Option1,QNo,PointNo ,CorrectNo) values (\"" + stmt1 + "\", NULL,\"" + phrase + "\"," + temp2.setNum(qNo) + "," + temp2.setNum(((Short *)object)->ptno[i+1])+",1)");
    41. }
    42. else {
    43. query = new QSqlQuery("select MAX(APNo) as APNo from ShAnsPts where QNo=" + temp2.setNum(qNo) +"&& PointNo=" + temp2.setNum(((Short *)object)->ptno[i+1]));
    44.  
    45. if(!query->first())
    46. {
    47. cout<<"There is no main phrase in this point ..... aborting\n";
    48. exit(-2);
    49. }
    50. aPNo = (query->value(0)).toInt();
    51. cout<<"This is apNo values"<<aPNo<<endl;
    52. stmt1=parseQuestion(stmt1); // function called for replacing tilde,cape symbol to angluar brackets
    53. stmt2temp=parseStepNo(stmt1,i,aPNo);
    54. cout<<"\nThis is the apno value required"<<aPNo<<endl;
    55. // stmt2temp=stmt1;
    56. stmt2=stmt2temp;
    57. cout<<"This is STatement2 value"<<stmt2<<endl;
    58. // (((baseFillChoose *)object)->stepno[i+1])=stepval[i];
    59. // cout<<"This is stepmark value"<<stepval[i]<<endl;
    60. query = new QSqlQuery("update ShAnsPts set Statement2 = \"" + stmt2 + "\" where APNo=" + temp2.setNum(aPNo));
    61. // query = new QSqlQuery("update ShAnsPts set StepMark = \"" + ((baseFillChoose *)object)->stepno[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    62. query = new QSqlQuery("update ShAnsPts set Q1Gif1 = \"" + ((Short *)object)->mgif[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    63. query = new QSqlQuery("update ShAnsPts set Q1Gif2 = \"" + ((Short *)object)->mgif1[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    64. query = new QSqlQuery("update ShAnsPts set StaticGif1 = \"" + ((Short *)object)->misc[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    65. query = new QSqlQuery("update ShAnsPts set voiceover = \"" + ((Short *)object)->voiceovers[i+1] + "\" where APNo=" + temp2.setNum(aPNo));
    66.  
    67. }
    68. }
    69. }
    70.  
    71. break;
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. int mainForm:arseOption(int ind,QString option, QString &stmt1, QString &phrase)
    2. {
    3. QTextStream cout(stdout, QIODevice::WriteOnly);
    4. int j = 0;
    5. int index = ind;
    6. cout<<"311 : parseOption : "<<option<<endl;
    7. cout<<"index&&\n"<<index<<endl;
    8. while(option[index] != '|')
    9. {
    10. stmt1[j] = option[index];
    11. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    12. if(option[index]=='\0')
    13. {
    14. stmt1[j] = '\0';
    15. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    16. option[0] = '\0';
    17. cout<<"option[0]\n"<<option[0]<<endl;
    18. return -1;
    19. }
    20. index++;
    21. j++;
    22. }
    23. stmt1[j] = '\0';
    24. cout<<"stmt1[j]**&\n"<<stmt1[j]<<endl;
    25. stmt1=stmt1.replace( "{sub}","<sub>");
    26. stmt1=stmt1.replace( "{/sub}","</sub>" );
    27.  
    28. cout<<"425 : "<<stmt1<<endl;
    29. j = 0;
    30. index++;
    31. while(option[index] != '\\')
    32. {
    33. phrase[j] = option[index];
    34. index++;
    35. j++;
    36. }
    37. phrase=phrase.replace( "{sub}","<sub>" );
    38. phrase=phrase.replace( "{sub}","<sub>" );
    39. cout<<"Phrase value"<<phrase<<endl;
    40. phrase[j] = '\0';
    41. cout<<"436 : "<<phrase<<endl;
    42.  
    43. return (index + 1);
    44.  
    45. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QString mainForm:arseQuestion(QString &stmt1)
    2. {
    3. QTextStream cout(stdout, QIODevice::WriteOnly);
    4. cout<<"It is coming inside the parse function"<<endl;
    5. stmt1=stmt1.replace( QChar('^'),QChar('<') );
    6. stmt1=stmt1.replace( QChar('~'),QChar('>') );
    7. stmt1=stmt1.replace( "{sub}","<sub>" );
    8. stmt1=stmt1.replace( "{/sub}","</sub>" );
    9. stmt1=stmt1.replace( "{sup}","<sup>" );
    10. stmt1=stmt1.replace( "{/sup}","</sup>" );
    11. return(stmt1);
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by gayathrisekaran; 8th November 2012 at 16:35. Reason: updated contents

  14. #11
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Program not running exited with code 0

    What do you think will this statement will do "stmt1[j] = '\0';"

    You are null terminating a QString with '\0', you don't have do it. All such assignments in your code will to crash your application one day or other.

    Either user all char * (C strings), or user all QStrings (and use them the way they are supposed to be used).

    I recommend to spend some time reading some Qt documentation and example, before writing such complicated statements for simple operations on at-least QString.

    by the way there are lot of variable which I cannot even image the type.
    what is type of object?
    what is type of baseFillChoose?
    what is type of temp2?
    and so may things...
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  15. The following user says thank you to Santosh Reddy for this useful post:

    gayathrisekaran (9th November 2012)

  16. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program not running exited with code 0

    ASSERT: "i >= 0" in file /usr/include/qt4/QtCore/qstring.h, line 875
    The program has unexpectedly finished.
    /home/tts/Desktop/QbankEditorAllrequirement/qbank exited with code 0
    You don't say what version of Qt you are using. In my Qt 4.8.2 source the only place in qstring.h with that Q_ASSERT statement implies that your code is attempting to retrieve a character from a string using a negative index. That is, somewhere you use code like:
    Qt Code:
    1. x = string[i];
    2. // or
    3. x = string.at(i);
    To copy to clipboard, switch view to plain text mode 
    the value of 'i' is negative. This is exactly the sort of thing Santosh has been asking you to consider.

    But the same code finely runs in qt3.
    The code will run without stopping if you compile a release version because the index idiot checks are not done. This is not the same thing as "finely runs". The program will still be broken in unpredictable ways.

    will you please explain what is call stack.
    When you run the program in your debugger it will stop the first time you try to access the string with a negative index. The Qt Creator panel that Santosh identified contains what is called a "backtrace", "stack trace", or "call stack". The first line is the last bit of code to execute, the line after that is where that block of code was called form, the line after that is where that block of code was called from etc... Read down the list until the first line that is in one of your source files. That is where your problem started. In Qt Creator you can double-click on that line and the "Locals and expressions" will display all the variables in scope at that time... find the problem here.

    If you are not using Qt Creator you need to find the equivalent of the backtrace and variable inspection facilities in you IDE... they all have them.

    Aside from that your constant, unsafe, C-style casting of the variable "object" to different types is just asking for trouble.

  17. The following user says thank you to ChrisW67 for this useful post:

    gayathrisekaran (9th November 2012)

  18. #13
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    I am using Qt4.6.2.
    While debugging, i am getting like this


    The inferior stopped because it received a signal from the Operating system


    Signal name : SIGABRT
    Signal meaning : Aborted
    The following is the exact piece of code where it points, When clicking ok.
    Qt Code:
    1. inline QCharRef QString::operator[](int i)
    2. { Q_ASSERT(i >= 0); return QCharRef(*this, i); } // here it points
    To copy to clipboard, switch view to plain text mode 

    filename is qstring.h
    Is there anything wrong in that.

    The exact problem i am having is,
    I've to enter the short question and short answers in seperate table in database through the editor.
    By entering the question and answers,
    it have to parse the question in "parseQuestion" function.

    Qt Code:
    1. QString mainForm::parseQuestion(QString &stmt1)
    2. {
    3. QTextStream cout(stdout, QIODevice::WriteOnly);
    4. cout<<"It is coming inside the parse function"<<endl;
    5. stmt1=stmt1.replace( QChar('^'),QChar('<') );
    6. stmt1=stmt1.replace( QChar('~'),QChar('>') );
    7. stmt1=stmt1.replace( "{sub}","<sub>" );
    8. stmt1=stmt1.replace( "{/sub}","</sub>" );
    9. stmt1=stmt1.replace( "{sup}","<sup>" );
    10. stmt1=stmt1.replace( "{/sup}","</sup>" );
    11. return(stmt1);
    12. }
    To copy to clipboard, switch view to plain text mode 

    And for the options,
    it have to parse the options n "parseOption" function.

    Qt Code:
    1. int mainForm::parseOption(int ind,QString option, QString &stmt1, QString &phrase)
    2. {
    3. QTextStream cout(stdout, QIODevice::WriteOnly);
    4. int j = 0;
    5. int index = ind;
    6. cout<<"311 : parseOption : option======="<<option<<endl;
    7. cout<<"index&&\n"<<index<<endl;
    8. cout<<"stmt1====\n"<<stmt1<<endl;
    9. while(option[index] != '|')
    10. {
    11. stmt1[j] = option[index];
    12. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    13. if(option[index]=='\0')
    14. {
    15. // stmt1[j] = '\0';
    16. cout<<"stmt1[j]\n"<<stmt1[j]<<endl;
    17. // option[0] = '\0';
    18. cout<<"option[0]\n"<<option[0]<<endl;
    19. return -1;
    20. }
    21. index++;
    22. j++;
    23. }
    24. // stmt1[j] = '\0';
    25. cout<<"stmt1[j]**&\n"<<stmt1[j]<<endl;
    26. stmt1=stmt1.replace( "{sub}","<sub>");
    27. stmt1=stmt1.replace( "{/sub}","</sub>" );
    28.  
    29. cout<<"425 : "<<stmt1<<endl;
    30. j = 0;
    31. index++;
    32. while(option[index] != '\\')
    33. {
    34. phrase[j] = option[index];
    35. index++;
    36. j++;
    37. }
    38. phrase=phrase.replace( "{sub}","<sub>" );
    39. phrase=phrase.replace( "{sub}","<sub>" );
    40. cout<<"Phrase value"<<phrase<<endl;
    41. phrase[j] = '\0';
    42. cout<<"436 : "<<phrase<<endl;
    43.  
    44. return (index + 1);
    45.  
    46. }
    To copy to clipboard, switch view to plain text mode 

    But in the "parseOption" function also it is parsing the questions itself.
    I am compiling my code in "debug" mode only
    Do you have any idea why it is parsing like this, and please tel me if any changes to be done in code
    Last edited by gayathrisekaran; 9th November 2012 at 09:07. Reason: updated contents

  19. #14
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    The "baseFillChoose" is a class and is just to declare the pageno etc...

    Qt Code:
    1. class baseFillChoose: public base
    2. {
    3. public:
    4. QString stmt[2];
    5. QString options[150];
    6. QString voiceovers[150];
    7. QString misc[150];
    8. QString mgif[150];
    9. QString mgif1[150];
    10. int ptno[150];
    11. QString chapter;
    12. QString Queswav;
    13. QString Queslist;
    14. QString ChooseType;
    15. int pageNo,qNo,correctNo;
    16. int apno[150];
    17. int qnumber;
    18. QString stepno[150];
    19. QString stepval[150];
    20. baseFillChoose();
    21. virtual bool checkFilled();
    22. virtual int getNumStmt();
    23. virtual int getNumOpt();
    24. virtual int getNumVoiceOvers();
    25. virtual int getNumMisc();
    26. virtual int getNumMgifs();
    27. virtual int getNumMgifs1();
    28.  
    29. virtual ~baseFillChoose();
    30.  
    31. };
    32.  
    33. /* fillups class */
    34. class FillUps : public baseFillChoose {};
    35.  
    36. /* choose class */
    37. class Choose : public baseFillChoose{};
    38.  
    39. /* short answers class */
    40. class Short : public baseFillChoose
    41. {
    42.  
    43. };
    44.  
    45. /* long answers class */
    46. class Long : public baseFillChoose
    47. {
    48.  
    49. };
    50.  
    51.  
    52. /* match class */
    53. class basematch : public baseFillChoose
    54. {
    55. public:
    56.  
    57. QString word[2];
    58. QString matchword[2];
    59. QString matchid[2];
    60. QString voiceovers[2];
    61. QString mgif[2];
    62. QString mgif1[2];
    63. QString ChooseType;
    64. QString Queswav;
    65. basematch();
    66.  
    67. virtual bool checkFilled();
    68. virtual bool checkMatchFilled();
    69. virtual int getNumStmt();
    70. virtual int getNumOpt();
    71. virtual int getNumVoiceOvers();
    72. virtual int getNumMgifs();
    73. virtual int getNumMgifs1();
    74. virtual ~basematch();
    75. };
    76.  
    77. class Match : public basematch{};
    To copy to clipboard, switch view to plain text mode 
    The following code is in same file commitdb.cpp.

    Qt Code:
    1. case SHORT:
    2. object = new Short(); // store the values from dom tree to objects
    3. ((baseFillChoose *)object)->pageNo = pageNo;
    4. ((baseFillChoose *)object)->ChooseType = ChooseType;
    5. ((baseFillChoose *)object)->Queswav = Queswav;
    6. ((Short *)object)->qnumber = qnumber;
    7. ((Short *)object)->stmt[0]="";
    8. ((Short *)object)->stmt[0] = ((listListNodes.item(0).cloneNode()).firstChild()).nodeValue();
    9. ((Short *)object)->mgif[0] = (((listListNodes.item(0)).cloneNode()).toElement()).attribute("mgif");
    10. ((Short *)object)->mgif1[0] = (((listListNodes.item(0)).cloneNode()).toElement()).attribute("mgif1");
    11. ((Short *)object)->misc[0] = (((listListNodes.item(0)).cloneNode()).toElement()).attribute("misc");
    12. /*getting options*/
    13.  
    14. i = 0;
    15. cout<<"172: enter..... SHort\n";
    16. while(i<listListNodes.count())
    17. {
    18. ((Short *)object)->options[i] = ((listListNodes.item(i)).cloneNode()).firstChild().nodeValue();
    19. ((Short *)object)->voiceovers[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("voiceover");
    20. ((Short *)object)->mgif[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("mgif");
    21. ((Short *)object)->mgif1[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("mgif1");
    22. ((Short *)object)->misc[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("misc");
    23. ((Short *)object)->ptno[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("ptno").toInt();
    24. ((Short *)object)->apno[i+1] = (((listListNodes.item(i)).cloneNode()).toElement()).attribute("apno").toInt();
    25. i++;
    26. }
    27. object->stmtStartPara = 0;
    28. object->optStartPara = object->getNumStmt() + 1;
    29. object->endPara = object->optStartPara + object->getNumOpt();
    30.  
    31. break;
    To copy to clipboard, switch view to plain text mode 

  20. #15
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program not running exited with code 0

    Quote Originally Posted by gayathrisekaran View Post
    I am using Qt4.6.2.
    While debugging, i am getting like this



    The following is the exact piece of code where it points, When clicking ok.
    Qt Code:
    1. inline QCharRef QString::operator[](int i)
    2. { Q_ASSERT(i >= 0); return QCharRef(*this, i); } // here it points
    To copy to clipboard, switch view to plain text mode 

    filename is qstring.h
    Is there anything wrong in that.
    No, there's nothing wrong with that. It is perfectly sane code that defends against being given bad inputs. The thing is, that is not your code. You seem to have missed this bit about the call stack:
    Quote Originally Posted by Me
    The first line is the last bit of code to execute, the line after that is where that block of code was called form, the line after that is where that block of code was called from etc... Read down the list until the first line that is in one of your source files. That is where your problem started. In Qt Creator you can double-click on that line and the "Locals and expressions" will display all the variables in scope at that time... find the problem here.
    Rather than post your entire program and expect someone else to work out where the problem is use the tools you already have to isolate the problem. We have already told you what the likely problem type is.

  21. The following user says thank you to ChrisW67 for this useful post:

    gayathrisekaran (10th November 2012)

  22. #16
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    No no its not like that guru. I am not expecting someone to check the problem.
    I was seeking the help,
    I'm debugging it and trying to find out .
    What i thought is if you have come across the same piece of code then it would be helpful to me.
    So i pasted the code.
    Last edited by gayathrisekaran; 12th November 2012 at 04:46. Reason: updated contents

  23. #17
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    I checked my code and did some corrections.

    Instead of returning index value as -1

    Qt Code:
    1. return -1;
    To copy to clipboard, switch view to plain text mode 
    I returned the index itself

    Qt Code:
    1. return (index);
    To copy to clipboard, switch view to plain text mode 

    Also in the case SHORT:
    Instead of checking the condition for executing query for inserting into answer table,

    Qt Code:
    1. if(index=-1)
    To copy to clipboard, switch view to plain text mode 
    I checked the condition,

    Qt Code:
    1. if((((Short *)object)->options[i])[index]!='\0')
    To copy to clipboard, switch view to plain text mode 

    Now it is working fine and all the questions and answers are entering to the main xml file also to the database in the appropriate table.

    Thanks a lot Santosh Reddy and ChrisW67 for your useful posts.
    Thanks & Regards

  24. #18
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program not running exited with code 0

    Why on earth are you doing all this casting of your Short * object to Short * and baseFillChoose * all over the place? Do you not understand how inheritance works in C++? You created a Short * instance. Just use it without all the casting. It makes your code almost incomprehensible.

    And the long strings of method().method().method().method()... calls are guaranteed to cause you a big headache if one of those calls in the middle returns something unexpected and the rest of the calls fall apart as a result. Look at how long it took you to find the problem in your original post.

    Please, do not work on any defence-related projects until you get a better understanding of C++. The world will be a safer place.

  25. The following user says thank you to d_stranz for this useful post:

    gayathrisekaran (26th November 2012)

  26. #19
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Program not running exited with code 0

    No d_stranz, i haven't did the code. Before 7years someone did this code in qt3. Now i was supposed to do the same in qt4. For the past 2months i was trying to solve the problem. If i did it means surely i wont write this much complicated code as a beginner. Anyway i wont write such a complicated code until i completely understand and wellversed in c++. Thank you d_stranz.

Similar Threads

  1. exited with code -1073741819
    By cic in forum Qt Programming
    Replies: 4
    Last Post: 11th November 2011, 23:39
  2. Running example project with mingw gives "... exited with code -1073741792" error
    By sibercekirge in forum Installation and Deployment
    Replies: 8
    Last Post: 31st May 2011, 17:33
  3. Program exited with code 03
    By Fallen_ in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2010, 23:09
  4. name.exe exited with code 1.
    By Fallen_ in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2010, 01:17
  5. Replies: 8
    Last Post: 28th January 2010, 06:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.