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 <Friedemann.Kleint@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Sergio Martins 2018-02-25 19:14:10 +00:00 committed by Sérgio Martins
parent 50315cc56e
commit 2a9cdd88b0
1 changed files with 7 additions and 2 deletions

View File

@ -44,6 +44,7 @@
#include "private/qcssutil_p.h"
#include <qdebug.h>
#include <qdir.h>
#include <qapplication.h>
#if QT_CONFIG(menu)
#include <qmenu.h>
@ -952,8 +953,12 @@ QRenderRule::QRenderRule(const QVector<Declaration> &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;