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
This commit is contained in:
Marco Martin 2009-01-22 19:59:25 +00:00
parent 2836267745
commit c532c9fda5
2 changed files with 15 additions and 5 deletions

14
svg.cpp
View File

@ -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;

View File

@ -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<QString, QSet<QString> >::iterator it = d->invalidElements.find(image);