Results 1 to 4 of 4

Thread: Unable to terminate QCoreApplication

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Unable to terminate QCoreApplication

    Hello,
    I am trying to connect to a host in my core application. If socket can connect to the host; no problem...But if it cannot resolve the hostname, the application stucks there. The application doesn't crash; but just refuses to exit, after that point...

    I tried QCoreApplication::exit() and standart c library exit() functions, none could terminate the program. Is there any way to exit the program, no matter how?

    that is the stubborn connecttohost function:
    Qt Code:
    1. d->socket->connectToHost( d->pop3_server , d->port );
    To copy to clipboard, switch view to plain text mode 

    I tried (not good but, need it.. ):
    Qt Code:
    1. QTimer::singleShot(20000, this, SLOT(exitnow()));
    To copy to clipboard, switch view to plain text mode 

    my slot:
    Qt Code:
    1. void Pop3::exitnow()
    2. {
    3. QCoreApplicaition::exit(0);
    4. }
    To copy to clipboard, switch view to plain text mode 

    also tried:
    Qt Code:
    1. void Pop3::exitnow()
    2. {
    3. exit(0);
    4. }
    To copy to clipboard, switch view to plain text mode 

    I debugged the application and saw that the exitnow() slot is called;but the application doesn't terminate.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Unable to terminate QCoreApplication

    Your application is hanging at the resolving code (probably somewhere in the operating system) and it can't get back to the event loop thus the exit code is not executed. This is actually the fault of your operating system as it doesn't notify the application it can't resolve the host and instead it keeps trying. I don't think there is much you can do beside pressing CTRL+C.

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Unable to terminate QCoreApplication

    I see. But i will use that application on an embedded system without a keyboard interface(works with voice commands). Isn't there any safer method to overcome this issue.

  4. #4
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Unable to terminate QCoreApplication

    I connected the error() signal of socket to my erroroccured() slot:

    Qt Code:
    1. void Pop3::errorOccured(QAbstractSocket::SocketError error)
    2. {
    3. d->socket->abort();//critical part
    4. exit(0);
    5. }
    To copy to clipboard, switch view to plain text mode 

    It terminates the application now...

Similar Threads

  1. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  2. Replies: 1
    Last Post: 7th August 2008, 13:46
  3. Replies: 4
    Last Post: 27th July 2006, 11:13

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.