Weird crash with QSystemTrayIcon on OSX
-
What happens if you call QSystemTrayIcon->hide() before you delete it. Also try using QSystemTrayIcon->deleteLater() instead of delete QSystemTrayIcon;.
Sometimes there are things pending for the object and calling deleteLater allows the event loop (where you are crashing) to process the signals and events then delete the item automatically for you. This can prevent crashes in certain circumstances and could be your issue right here.
-
We've tried multiple variations of this. We've tried
@delete m_sysTrayIcon;
@We've tried
@m_sysTrayIcon->hide();
@We've tried
@m_sysTrayIcon->hide();
m_sysTrayIcon->deleteLater();
@We would have tried
@m_sysTrayIcon->close();
@...but QSystemTrayIcon doesn't have a close() method!
In every one of these cases, our QSystemTrayIcon gets nicely deleted (according to the printout we have in our dtor), but we still get the crash.
QSystemTrayIcon seems to be a very odd beast, being renderable but not descended from QWidget. The Windows build of this code works perfectly, and has for some time now. But the OSX version gets this mysterious crash.
-
Hi,
Can you try with the latest current version that is 4.8.6 ?
-
Ok - I'll try it with 4.8.6. Our application is still 32-bit so unfortunately this isn't as simple as dropping in a binary update - I have to put together a special 32-bit build.
-
Then first try with the pre-built package, it should crash the same unless you are doing a special build
-
Is there a prebuilt 32-bit OSX build? If so I'd gladly use that. I wasn't aware that such a thing existed.
-
No, there's no 32Bit build since a long time. Just the 64, but Qt is not really hard to compile on OS X
-
I'm running into a whole lot of build breaks with 4.8.6 and the latest xcode in 32-bit. I'm making a lot of patches to get 4.8.6 to build, and I've completely given up on phonon.
Are 32-bit OSX builds part of your continuous integration system? It seems like recent versions of clang have broken a whole lot of things in Qt...
-
What if instead of completely deleting the system tray icon you just hide it in the mode where you don't want to display it?
Does that cause a crash too? Or is it just the cleanup? Then you can create it, show it when you want, hide it when you don't, and it looks/acts like the same thing to the end user.
Also, another option is to use the OSX raw code for tray icons instead of the Qt stuff to work around the bug. If you are stuck on old versions of Qt maybe this is an option for you to just #ifdef some mac specific tray icon code. Not ideal but an easy solution.
-
I don't know, I don't work for Digia, however you can find information about the CI "here":http://qt-project.org/wiki/CI_Overview
But like I said, test with the 64 bit prebuilt package. Creating a minimal compilable example that reproduce the behavior will help creating a patch.