Bug 507068 - QStyleFactory::create("Breeze"); segfaults before QApplication constructor
Summary: QStyleFactory::create("Breeze"); segfaults before QApplication constructor
Status: RESOLVED NOT A BUG
Alias: None
Product: Breeze
Classification: Plasma
Component: QStyle (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-15 13:33 UTC by torokati44
Modified: 2025-08-28 17:44 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.