QT exited with code -1073741510



  • i create a console program,but when i close console program or ctrl+c, QT displays exited with code -1073741510 ,why? where is wrong?

    @int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    qDebug()<<"hello qt";
    return a.exec();
    }@

    qxoz:code tags



  • Good question .. !! BTW.. There is nothing wrong in that. but i also want to know what is that number which written in "exited with code -1073741510".



  • -1073741510 = 0xc000013a

    According to "NTSTATUS values":http://msdn.microsoft.com/en-us/library/cc704588.aspx it is

    @
    0xC000013A
    STATUS_CONTROL_C_EXIT

    {Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.
    @



  • 3Q


  • Moderators

    You don't need an event loop, so don't call exec().

    @
    // Replace this...
    return a.exec();

    // ...with this:
    return 0;
    @

    If you call exec(), you need to quit your program by triggering QCoreApplication::exit() or QCoreApplication::quit()



  • // Replace this...
    return a.exec();

    // ...with this:
    return 0;

    but how can i get i get terminate message from QCoreApplication::notify() or else method.



  • I don't think QCoreApplication::notify(), which is used to deliver events, is what you want.

    There's a QCoreApplication::aboutToQuit() signal that indicates that the main event loop is about to terminate, which works pretty well for applications that end main() with "return app.exec();" Minus an event loop, much of Qt won't be of use.

    Perhaps a function that uses printf() and is registered with atexit() will work.


  • Moderators

    [quote author="foxgod" date="1402987828"]but how can i get i get terminate message from QCoreApplication::notify() or else method.[/quote]What do you want to do with the message?



  • i want to get console close's message ,when i know the console is closed,then i want to execute some program.



  • @void terminateTest()
    {
    qDebug()<<"program is over"<<endl;
    rootThreadpro.aboutToQuit();
    }

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    qDebug()<<"Root\n";
    atexit(terminateTest);
    rootThreadpro.StartServer(); 
    return a.exec&#40;&#41;;
    

    }
    @

    this can solve currently question , antthing also?


  • Moderators

    [quote author="foxgod" date="1402989786"]i want to get console close's message ,when i know the console is closed,then i want to execute some program.[/quote]You cannot get that message in your application. When you close the console, it terminates your application.

    Just launch your other program before return 0;

    I don't recommend closing a console application by clicking the 'X' or Ctrl-C. If your program terminates like this, it won't be able to clean up. Sometimes, this can corrupt your data files.



  • It looks like atexit() won't work without some additional handling.

    bq. Functions registered using atexit() (and on_exit(3)) are not called if a process terminates abnormally because of the delivery of a signal.


  • Moderators

    Like I said, do not use Ctrl-C, and do not close your console by clicking the 'X'. These are dangerous ways to stop a program.

    Why don't you quit your program properly?

    Or, if you really want to close by clicking the 'X', create a QWidget-based GUI. Then, when you click the 'X', you will get a QCloseEvent.



  • Sometimes users do unexpected things.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.