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

QSessionManager cancel() function does not work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.3.1
    • None
    • Windows 7 64Bit
      Ubuntu 14.04 (Unity desktop) 64Bit

    Description

      I want my application to prevent a systen shutdown in some cases.
      QSessionManager should do the trick, when calling it's cancel() function.

      So I have a code like this from the documentation:

      MyMainWidget::MyMainWidget(QWidget *parent)
          :QWidget(parent)
      {
          connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(commitData(QSessionManager&)));
      }
      
      void MyMainWidget::commitData(QSessionManager& manager)
      {
          if (m_prevent_shutdown) {
              qDebug() << Q_FUNC_INFO << "cancel the shutdown";
              manager.cancel();
          }
      }
      

      This neither works in Windows 7, nor in Ubuntu 14.04.
      But from the debug output I can see that the cancel() is called right in front of the Windows/Ubuntu shutdown, after pressing the systems shutdown button.

      In Windows, handling WM_QUERYENDSESSION "manually" in a custom QAbstractNativeEventFilter does work.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              liaqi Liang Qi
              schwann Guenter Schwann
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes