From 0f88982f088ca50046eca0961361f4c48045c611 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 29 Apr 2025 20:55:30 +0200 Subject: [PATCH] Widgets/Stylesheets: compile without FEATURE_style_stylesheet Make sure to not compile the stylesheet sources when FEATURE_style_stylesheet is disabled, also don't include the relevant headers in this case. Fixes: QTBUG-136341 Change-Id: I4fc2de2fcba004b93140809ef79374401209f14a Reviewed-by: Axel Spoerl (cherry picked from commit e57fff63419867d59b6067fc1a5a3495678708dc) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/CMakeLists.txt | 8 ++++++-- src/widgets/kernel/qapplication.cpp | 2 ++ src/widgets/kernel/qtooltip.cpp | 2 ++ src/widgets/kernel/qwidget.cpp | 2 ++ src/widgets/widgets/qdockwidget.cpp | 1 - src/widgets/widgets/qlabel.cpp | 4 +++- src/widgets/widgets/qlineedit.cpp | 3 ++- 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 0c1a17ca187..29f3de6a789 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -43,8 +43,6 @@ qt_internal_add_module(Widgets styles/qstyleoption.cpp styles/qstyleoption.h styles/qstylepainter.cpp styles/qstylepainter.h styles/qstyleplugin.cpp styles/qstyleplugin.h - styles/qstylesheetstyle.cpp styles/qstylesheetstyle_p.h - styles/qstylesheetstyle_default.cpp util/qcolormap.cpp util/qcolormap.h util/qsystemtrayicon.cpp util/qsystemtrayicon.h util/qsystemtrayicon_p.h widgets/qabstractscrollarea.cpp widgets/qabstractscrollarea.h widgets/qabstractscrollarea_p.h @@ -425,6 +423,12 @@ qt_internal_extend_target(Widgets CONDITION QT_FEATURE_animation styles/qstyleanimation.cpp styles/qstyleanimation_p.h ) +qt_internal_extend_target(Widgets CONDITION QT_FEATURE_style_stylesheet + SOURCES + styles/qstylesheetstyle.cpp styles/qstylesheetstyle_p.h + styles/qstylesheetstyle_default.cpp +) + qt_internal_extend_target(Widgets CONDITION QT_FEATURE_style_windows SOURCES styles/qwindowsstyle.cpp styles/qwindowsstyle_p.h diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ef7dd981320..d4ae436ae4d 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -33,7 +33,9 @@ #include "private/qguiapplication_p.h" #include "qcolormap.h" #include "qdebug.h" +#if QT_CONFIG(style_stylesheet) #include "private/qstylesheetstyle_p.h" +#endif #include "private/qstyle_p.h" #if QT_CONFIG(messagebox) #include "qmessagebox.h" diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 5485777eabb..eeb89adf8f3 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -16,7 +16,9 @@ #include #include #include +#if QT_CONFIG(style_stylesheet) #include +#endif #include #include diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index ff714a00154..f2c2bcf7218 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -36,7 +36,9 @@ #include "qwhatsthis.h" #endif #include "qdebug.h" +#if QT_CONFIG(style_stylesheet) #include "private/qstylesheetstyle_p.h" +#endif #include "private/qstyle_p.h" #include "qfileinfo.h" #include "qscopeguard.h" diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 4387b7626a7..33e9c8f3e88 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 12327e90af8..bab24211e87 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -8,9 +8,11 @@ #include "qstyleoption.h" #include "qlabel_p.h" #include "private/qhexstring_p.h" -#include "private/qstylesheetstyle_p.h" #include +#if QT_CONFIG(style_stylesheet) +#include "private/qstylesheetstyle_p.h" +#endif #if QT_CONFIG(abstractbutton) #include "qabstractbutton.h" #endif diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index b08fa06ea16..00cbbb9d187 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -41,8 +41,9 @@ #if QT_CONFIG(itemviews) #include "qabstractitemview.h" #endif +#if QT_CONFIG(style_stylesheet) #include "private/qstylesheetstyle_p.h" - +#endif #if QT_CONFIG(shortcut) #include "private/qapplication_p.h" #include "private/qshortcutmap_p.h"