From 2a9cdd88b027cdd7304d0abff17299688551ba81 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sun, 25 Feb 2018 19:14:10 +0000 Subject: [PATCH] stylesheets: Don't fail silently with invalid background-images Print a qWarning, otherwise this is very hard to notice Change-Id: I882f97583071e786d5aa06f6eeb485da4fc646db Reviewed-by: Friedemann Kleint Reviewed-by: David Faure --- src/widgets/styles/qstylesheetstyle.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e34bae64ce..5c9d19a49d 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -44,6 +44,7 @@ #include "private/qcssutil_p.h" #include +#include #include #if QT_CONFIG(menu) #include @@ -952,8 +953,12 @@ QRenderRule::QRenderRule(const QVector &declarations, const QObject Attachment attachment = Attachment_Scroll; origin = Origin_Padding; Origin clip = Origin_Border; - if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) - bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip); + if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) { + QPixmap pixmap(uri); + if (!uri.isEmpty() && pixmap.isNull()) + qWarning("Could not create pixmap from %s", qPrintable(QDir::toNativeSeparators(uri))); + bg = new QStyleSheetBackgroundData(brush, pixmap, repeat, alignment, origin, attachment, clip); + } QBrush sfg, fg; QBrush sbg, abg;