From c532c9fda548bccf036942c872d2631fa4be8ca2 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 22 Jan 2009 19:59:25 +0000 Subject: [PATCH] initialize the natural size also for absolute path svgs never insert the whole image (no element) in the invalid list to backport or not to backport? CCMAIL plasma-devel@kde.org svn path=/trunk/KDE/kdelibs/; revision=915328 --- svg.cpp | 14 +++++++++----- theme.cpp | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/svg.cpp b/svg.cpp index 7a6c3ede1..c7c1008b0 100644 --- a/svg.cpp +++ b/svg.cpp @@ -140,20 +140,24 @@ class SvgPrivate q, SLOT(colorsChanged())); } + } else if (QFile::exists(imagePath)) { + path = imagePath; + } else { + kDebug() << "file '" << path << "' does not exist!"; + } + + //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(imagePath)) { QRectF rect; bool found = Theme::defaultTheme()->findInRectsCache(path, "_Natural", rect); - if (found && !rect.isValid()) { + if (!found) { createRenderer(); naturalSize = renderer->defaultSize(); Theme::defaultTheme()->insertIntoRectsCache(path, "_Natural", QRectF(QPointF(0,0), naturalSize)); } else { naturalSize = rect.size(); } - } else if (QFile::exists(imagePath)) { - path = imagePath; - } else { - kDebug() << "file '" << path << "' does not exist!"; } return updateNeeded; diff --git a/theme.cpp b/theme.cpp index df9c6bdac..13e36a4b7 100644 --- a/theme.cpp +++ b/theme.cpp @@ -585,6 +585,12 @@ bool Theme::findInRectsCache(const QString &image, const QString &element, QRect return true; } + //A single _ means the element is empty and we're asked for the size of + //the whole image, so the whole image is never invalid + if (element.count('_') == 1) { + return false; + } + bool invalid = false; QHash >::iterator it = d->invalidElements.find(image);