Comment 0 for bug 1574699

Revision history for this message
ogoffart (hohagh-3) wrote :

in qppmenu-qt5 in ubuntu 16.4, the AppMenuPlatformSystemTrayIcon assumes there is only one instance of a QPlatformSystemTrayIcon: it register the same sbus name for all the instances. In fact, there is one instance of QPlatformSystemTrayIcon per instance of QSystemTrayIcon, and one temporary is created for QSystemTrayIcon::isSystemTrayAvailable.

This breaks the owncloud client [issue https://github.com/owncloud/client/issues/4693 ]

This example reproduces the problem:

```
#include <QtWidgets>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QImage img(64,64, QImage::Format_ARGB32);
    img.fill(Qt::red);
    QSystemTrayIcon sti(QIcon(QPixmap::fromImage(img)));
    sti.show();

     QSystemTrayIcon::isSystemTrayAvailable(); // with this line, the QSystemTrayIcon does not appear
     // comment the previous line to see that the QSystemTrayIcon works and that there is a bug in that line

    return a.exec();
}
```

This testcase shows that the AppMenuPlatformSystemTrayIcon::~AppMenuPlatformSystemTrayIcon called by the temporary object created inside QSystemTrayIcon::isSystemTrayAvailable unregisters the icon.