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

DBus QSystemTrayIcon does not work or causes crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.5.0
    • Fix Version/s: 5.5.1, 5.6.1
    • Component/s: QPA: X11/XCB
    • Labels:
      None
    • Environment:
      Qt 5.5.0 gcc 64 from installer, KDE 4.13.3-0ubuntu0.2

      Description

      When the DBus / StatusNotifier based system tray icon is used with Qt 5.5.0, rebuilding the tray menu leads to a bad state. In this state, the old menu continues to be shown, but clicking on actions either has no effect or causes a crash.

      Test code:

      #include <QApplication>
      #include <QSystemTrayIcon>
      #include <QMenu>
      #include <QDebug>
      #include <QTimer>
      
      class Handler : public QObject
      {
          Q_OBJECT
      
      public slots:
          void trigger()
          {
              qDebug() << "Triggered";
          }
      
          void setupMenu()
          {
              menu.clear();
      
              QAction *action1 = menu.addAction("Debug output: Triggered");
              connect(action1, SIGNAL(triggered()), SLOT(trigger()));
      
              QAction *action2 = menu.addAction("Re-setup menu");
              connect(action2, SIGNAL(triggered()), SLOT(setupMenu()));
      
              menu.addAction(QString::number(rand()));
          }
      
      public:
          QMenu menu;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QSystemTrayIcon tray;
          Handler h;
      
          tray.setContextMenu(&h.menu);
          tray.show();
          h.setupMenu();
      
          return a.exec();
      }
      
      #include "main.moc"
      

      After clicking Re-setup menu the old menu continues to be shown and actions no longer work.

      Olivier Goffart (Woboq GmbH) suggested this may be related to menuItemsById not being cleaned up in http://code.woboq.org/qt5/qtbase/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp.html#menuItemsByID

      See also https://github.com/owncloud/client/issues/3656 and possibly QTBUG-46293.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-47863
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              srutledg Shawn Rutledge
              Reporter:
              ckamm Christian Kamm
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes