Steps to reproduce: - build Qt's example applications - launch the quickcontrols2/gallery/gallery example - set settings/Style to org.kde.desktop and restart
It will. Don't use QQC2-desktop-style without a QApplication as it needs the QStyle.
Well, that really puts a huge damper on using this plugin; setting QT_QUICK_CONTROLS_STYLE=org.kde.desktop means random (from the user's PoV) applications will start to crash. Letting code crash like this is really sloppy too, IMHO. Apparently it's not possible to let the style plugin deactivate itself when `qApp->style() == NULL`, but it can at least provoke a more or less clean application exit by not registering anything in registerTypes. And maybe it's not that expensive to let the style become a big NOOP in this situation.
Created attachment 113842 [details] possible crash avoidance This is a simple workaround to prevent applications from crashing. I haven't found a more elegant workaround (like a fallback to the default QQ2 style) but IMHO this still beats letting the code dereference null pointers knowingly.
Patch makes sense. Maybe QApplication::style as its static and qApp isn't a QApplication. Ship it.
Git commit 1e02355c178600e89b8c45e6232b2a2dc811ccc6 by René J.V. Bertin. Committed on 24/11/2018 at 09:35. Pushed by rjvbb into branch 'master'. Support for QGuiApplication-based apps Wraps qApp->style() and creates a QStyle instance of the user's preferred widget style if qApp->style() returns null. This makes it safe to set QT_QUICK_CONTROLS_STYLE=org.kde.desktop and still run applications based on QuickControls2 (QGuiApplication) without crashing. Differential Revision: https://phabricator.kde.org/D14000 M +139 -117 plugin/kquickstyleitem.cpp M +7 -2 plugin/kquickstyleitem_p.h https://commits.kde.org/qqc2-desktop-style/1e02355c178600e89b8c45e6232b2a2dc811ccc6