Results 1 to 5 of 5

Thread: Shutdown on Mac failing

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Shutdown on Mac failing

    Hi,

    I am using qt 4.6.3 on mac.

    When I run my application and the user does a system shutdown. Somewhere in my app, the shutdown is intercepted and the shutdown canceled. I have made sure that none of the closeEvent accept the event. I also have my own QApplication and have connected commitDataRequest to slot (which is never getting called) and reimplemented commitData which is also never getting called.

    It looks like something much earlier stops it from happening. Has anyone experienced this?

    Thanks

  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: Shutdown on Mac failing

    Quote Originally Posted by ntp View Post
    I have made sure that none of the closeEvent accept the event.
    And that's exactly what prevents your system from shutting down.
    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
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Shutdown on Mac failing

    Thanks but actually, when I remove the code and let the default behavior happen, it still fails to close. I even experimented with a two line application:

    Qt Code:
    1. int main (int argc, char** argv) {
    2. QApplication app(argc, argv);
    3. return app.exec();
    4. }
    To copy to clipboard, switch view to plain text mode 
    and that will tell the system not to shut down.

    I started to look at the delegate. Is it at possible that this code from qcocooaapplicationdelegate_mac.mm is causing it to return with a NSTerminateCancel which stops the shutdown? Would a terminate from the mac system go through this code?

    Qt Code:
    1. // This function will only be called when NSApp is actually running. Before
    2. // that, the kAEQuitApplication apple event will be sendt to
    3. // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
    4. - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
    5. {
    6. Q_UNUSED(sender);
    7. // The reflection delegate gets precedence
    8. if (reflectionDelegate
    9. && [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) {
    10. return [reflectionDelegate applicationShouldTerminate:sender];
    11. }
    12.  
    13. if (qtPrivate->canQuit()) {
    14. if (!startedQuit) {
    15. startedQuit = true;
    16. qAppInstance()->quit();
    17. startedQuit = false;
    18. }
    19. }
    20.  
    21. if (qtPrivate->threadData->eventLoops.size() == 0) {
    22. // INVARIANT: No event loop is executing. This probably
    23. // means that Qt is used as a plugin, or as a part of a native
    24. // Cocoa application. In any case it should be fine to
    25. // terminate now:
    26. return NSTerminateNow;
    27. } else {
    28. // Prevent Cocoa from terminating the application, since this simply
    29. // exits the program whithout allowing QApplication::exec() to return.
    30. // The call to QApplication::quit() above will instead quit the
    31. // application from the Qt side.
    32. return NSTerminateCancel;
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 

  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: Shutdown on Mac failing

    How do you know it is your application that is preventing the shutdown? Do any other Qt applications behave that way?
    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
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Shutdown on Mac failing

    When I don't run my application, the system shuts down. When I ran that application that I included, the system did not shutdown either. (And the mac message dialog tells me that it is the application that is stopping it from shutting down). The application itself does exit (both mine and that one).

Similar Threads

  1. How to shutdown Linux machine from QT Program?
    By Kevin Hoang in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2010, 20:42
  2. QEventLoop and QThreadPool Shutdown Problems
    By shawno in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2010, 18:49
  3. Finalization on system shutdown
    By nomadoro in forum Qt Programming
    Replies: 4
    Last Post: 30th October 2009, 19:30
  4. Reboot/Shutdown Windows with startDetached
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 11th March 2009, 12:40
  5. closeEvent preventing shutdown
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2007, 19:41

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.