Results 1 to 6 of 6

Thread: Force Stop

  1. #1
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Force Stop

    If an application is started through Qt Creator 2 (no Debugging) a small red rectangle is enabled to stop the application. After a while Qt Creator ask for "Force Stop" because the application is not responding (happens with a simple Qt Console application). But even if I handle all possible Linux signals, I'm unable to gracefully quit the application. Does anyone now what happens behinde the scenes when the button is pressed (I was unable to see anything usefull through strace)?

  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: Force Stop

    Most likely Creator launches your program via QProcess so when you ask it to stop the program it either does QProcess::terminate() or QProcess::kill() (which of the two it is, you can check in the source code). If Creator asks to force stop, then most likely it tries with terminate() first and if it fails, it does kill().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Force Stop

    I handle SIGTERM and it seams that there is no sign, that this signal is sent to the process. I already looked and the source. It seems that there is RunControl class which only has the methods start/stop. I've to crawl a bit more deeply I guess.

  4. #4
    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: Force Stop

    Does the handler get activated if you run your program from the command line?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Force Stop

    Yes. kill <pid> works as expected. The signal handler only sets a boolean, the main loop quits when the boolean is set.

    When I analyzed the code correctly it looks like SIGTERM is not sent from Qt Creator when the Stop Button is pressed. Only a condition is checked if the process is still running. After the "Force Quit" button is pressed a SIGTERM is sent, and then a SIGKILL (through QProcess terminate and kill), but this is IMO too late (there is no reason the developer has to press the button always twice). If I'm not completly wrong here I think it's an inconvenient behaviour from Qt Creator.
    Last edited by Azraiyl; 16th November 2010 at 13:45.

  6. #6
    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: Force Stop

    My Creator simply asks me if I want to stop the program. I had situations when I pressed the stop switch by accident so I'm not that annoyed that a dialog pops up asking me whether I want to terminate the app. I'm sure disabling the dialog should be easy - just comment the appropriate line and rebuild the plugin responsible for handling the situation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. WebKit: how to force plugins (flash) to stop
    By rickyviking in forum Qt Programming
    Replies: 3
    Last Post: 10th September 2010, 16:31
  2. Any way to force a signal?
    By dbrmik in forum Qt Programming
    Replies: 7
    Last Post: 13th March 2009, 16:33
  3. QListView force redraw.
    By Dave Stewart in forum Qt Programming
    Replies: 4
    Last Post: 19th December 2007, 15:41
  4. how to force an exiting?
    By anli in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2006, 13:36
  5. force repaint
    By georgie in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 14:16

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.