Fix one source of log spam referenced in Bug 388389 (Empty filename passed to function)

Summary:
I found two places in plasma-framework svg.cpp (Plasma::Svg) that were triggering this message.

path variable was not being checked for empty before passing to QFile::exists().

This seems to be one source of the issue reported in [[ https://bugs.kde.org/show_bug.cgi?id=388389 | Bug 388389 ]]

Test Plan: Found that kicker was triggering this message and also plasmashell tooltips.

Reviewers: #frameworks, davidedmundson

Reviewed By: davidedmundson

Subscribers: ngraham, alexeymin, aacid, #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D9928
This commit is contained in:
Randy Kron 2018-01-20 22:21:07 +00:00 committed by David Edmundson
parent 55efe5ae63
commit 5eece6769f

View File

@ -237,7 +237,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
path = actualTheme()->imagePath(themePath);
themeFailed = path.isEmpty();
QObject::connect(actualTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
} else if (QFile::exists(actualPath)) {
} else if (QFileInfo::exists(actualPath)) {
QObject::connect(cacheAndColorsTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()), Qt::UniqueConnection);
path = actualPath;
} else {
@ -251,7 +251,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
// also images with absolute path needs to have a natural size initialized,
// even if looks a bit weird using Theme to store non-themed stuff
if ((themed && QFile::exists(path)) || QFile::exists(actualPath)) {
if ((themed && !path.isEmpty() && QFileInfo::exists(path)) || QFileInfo::exists(actualPath)) {
QRectF rect;
if (cacheAndColorsTheme()->findInRectsCache(path, QStringLiteral("_Natural_%1").arg(scaleFactor), rect)) {
@ -900,7 +900,7 @@ bool Svg::isValid() const
return true;
}
if (!QFile::exists(d->path)) {
if (d->path.isEmpty() || !QFileInfo::exists(d->path)) {
return false;
}