Bug 507068

Summary: QStyleFactory::create("Breeze"); segfaults before QApplication constructor
Product: [Plasma] Breeze Reporter: torokati44
Component: QStyleAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: kde, nate, noahadvs, uhhadd
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description torokati44 2025-07-15 13:33:55 UTC
SUMMARY

The official Qt docs say: doc.qt.io/qt-6/qapplication.html#setStyle-1

    Warning: To ensure that the application's style is set correctly, it is best to call this function before the QApplication constructor, if possible.

However, if the QStyle instance can't be created before QApplication, this isn't possible.

STEPS TO REPRODUCE

1. `QStyleFactory::create("Breeze");`
2. `new QApplication(...)`

OBSERVED RESULT

Segmentation fault.

EXPECTED RESULT

The style is created before QApplication successfully.

SOFTWARE/OS VERSIONS

Linux: 6.15.5-200.fc42.x86_64 (64-bit)
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION

```
#3  | Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/widgets/styles/qstylefactory.cpp", line 77, in qLoadPlugin<QStyle, QStylePlugin>
      Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/corelib/plugin/qfactoryloader_p.h", line 100, in create [0x7f5a452f30e6]
#2  | Source "/usr/src/debug/plasma-breeze-6.4.2-1.fc42.x86_64/kstyle/breezestyleplugin.cpp", line 15, in create
      Source "/usr/src/debug/plasma-breeze-6.4.2-1.fc42.x86_64/kstyle/breezestyleplugin.cpp", line 18, in create [0x7f5a3c50370b]
#1  | Source "/usr/src/debug/plasma-breeze-6.4.2-1.fc42.x86_64/kstyle/breezestyle.cpp", line 277, in make_unique<Breeze::WindowManager>
      Source "/usr/include/c++/15/bits/unique_ptr.h", line 1085, in Style [0x7f5a3c4d7d7a]
       1082:     _GLIBCXX23_CONSTEXPR
       1083:     inline __detail::__unique_ptr_t<_Tp>
       1084:     make_unique(_Args&&... __args)
      >1085:     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
       1086: 
       1087:   /** Create an array owned by a `unique_ptr`.
       1088:    *  @tparam _Tp An array type of unknown bound, such as `U[]`.
#0  | Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/corelib/kernel/qobject.cpp", line 2352, in d_func
    | Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/corelib/kernel/qobject.h", line 110, in qGetPtrHelper<QScopedPointer<QObjectData> >
    | Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/corelib/global/qtclasshelpermacros.h", line 137, in get
      Source "/usr/src/debug/qt6-qtbase-6.9.1-1.fc42.x86_64/src/corelib/tools/qscopedpointer.h", line 112, in installEventFilter [0x7f5a45b5d7fd]
Segmentation fault (Address not mapped to object [0x8])
Segmentation fault (core dumped)
```
Comment 1 Kai Uwe Broulik 2025-07-20 06:55:01 UTC
> it is best to call this function before the QApplication constructor, if possible.

“if possible”, clearly it’s not possible here. Breeze requires a qApp for the drag-on-empty-window area and probably other features. I don’t think we support what you’re doing here.