Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-102321

Qt application blocks macos shutdown, restart

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2, 6.2.4
    • QPA
    • None
    • macOS Big Sur(11.6)
      MacBook Pro(13-inch, M1, 2020)
      Chip Apple M1
      Memory 16GB
    • macOS

    Description

      Description: Qt application interrupts macOS from restarting or shut downing if any clean-up code in aboutToQuit signal emitted time take some time(from my side 200 ms is enough). OS always shows  

      Example:

      QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [](){
              // long time close opperation
              // write to file
              // save data in db
              // generation data and save on disk
              // and so on
              std::this_thread::sleep_for(std::chrono::milliseconds(10000));
          });

      Steps to reproduce:
      1 Run attached application
      2 Restart macOS

      Expected result: It is possible to clean-up code in any way without any interruptions and additional warnings from OS side.

      NOTE: - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
      return NSTerminateNow or NSTerminateCancel

      Suggestion: Consider returning NSTerminateLater and call 
      [NSApp replyToApplicationShouldTerminate:YES];
      in ~QApplication for example

      Attachments

        1. image-2022-04-05-16-56-55-373.png
          image-2022-04-05-16-56-55-373.png
          88 kB
        2. image-2022-10-11-16-43-06-402.png
          image-2022-10-11-16-43-06-402.png
          269 kB
        3. screenshot-1.png
          screenshot-1.png
          99 kB
        4. TerminationTest.trace.zip
          1.95 MB
        5. TerminationTest.zip
          4 kB
        6. TerminationTest 2.zip
          4 kB
        For Gerrit Dashboard: QTBUG-102321
        # Subject Branch Project Status CR V

        Activity

          People

            vestbo Tor Arne Vestbø
            evgenpervenenko Evgen Pervenenko
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change