rjvbb created this revision.
rjvbb added a reviewer: Framework: Syntax Highlighting.
Restricted Application added a project: Plasma.
Restricted Application added a subscriber: plasma-devel.
rjvbb requested review of this revision.

REVISION SUMMARY
  See https://bugs.kde.org/show_bug.cgi?id=396287
  
  Setting `QT_QUICK_CONTROLS_STYLE=org.kde.desktop` used to be safe but has 
started the cause applications to crash. Or I just never ran into what seem to 
be random (from a Joe User experience) but in fact are QGuiApplication-based 
applications.
  
  This patch presents a proof-of-concept fix that makes it safe to set 
`QT_QUICK_CONTROLS_STYLE` or whatever other options there are to use the QQC2 
desktop style in all applications that use QuickControls2.
  The current implementation creates a local instance of Qt's built-in Fusion 
style, and probably doesn't need to create a new instance for each new 
KQuickStyleItem instance. Being a Tier3 framework it should be possible to 
fetch the current desktop style through KConfig, in which case creating a new 
QStyle instance would be (more) justified. There's probably some optimisation 
to be done here though I'm not convinced it will make any difference in 
practice, in the general context of using QtQuick.
  
  An alternative approach would be to do the programmatic equivalent of the 
command-line override (e.g. `quickcontrols2/gallery/gallery -style Default`) 
but I have not yet been able to figure out if it is possible to change the 
QQuickStyle at this point.

TEST PLAN
  Tested with
  
    > env QT_QUICK_CONTROLS_STYLE=org.kde.desktop 
/path/to/qt5-examples/quickcontrols2/gallery/gallery
  
  before: immediate crash because the plugin dereferences a NULL qApp->style() 
without flinching
  after: practically normal behaviour that is certainly preferable to crashing 
due to a potential security exploit.

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #framework_syntax_highlighting
Cc: plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol, mart

Reply via email to