be a bit more careful with accessing the internal theme pointer, try a bit harder not to cause creation of the defaultTheme if it hasn't been
svn path=/trunk/KDE/kdelibs/; revision=969534
This commit is contained in:
parent
9622b2cfe8
commit
f44b6a256f
54
svg.cpp
54
svg.cpp
@ -123,8 +123,11 @@ class SvgPrivate
|
|||||||
// then lets not schedule a repaint because we are just initializing!
|
// then lets not schedule a repaint because we are just initializing!
|
||||||
bool updateNeeded = true; //!path.isEmpty() || !themePath.isEmpty();
|
bool updateNeeded = true; //!path.isEmpty() || !themePath.isEmpty();
|
||||||
|
|
||||||
QObject::disconnect(theme, SIGNAL(themeChanged()),
|
if (themed) {
|
||||||
|
QObject::disconnect(actualTheme(), SIGNAL(themeChanged()),
|
||||||
q, SLOT(themeChanged()));
|
q, SLOT(themeChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
q, SLOT(colorsChanged()));
|
q, SLOT(colorsChanged()));
|
||||||
|
|
||||||
@ -133,12 +136,8 @@ class SvgPrivate
|
|||||||
themePath.clear();
|
themePath.clear();
|
||||||
|
|
||||||
if (themed) {
|
if (themed) {
|
||||||
if (!theme) {
|
|
||||||
theme = Plasma::Theme::defaultTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
themePath = imagePath;
|
themePath = imagePath;
|
||||||
QObject::connect(theme, SIGNAL(themeChanged()),
|
QObject::connect(actualTheme(), SIGNAL(themeChanged()),
|
||||||
q, SLOT(themeChanged()));
|
q, SLOT(themeChanged()));
|
||||||
|
|
||||||
// check if svg wants colorscheme applied
|
// check if svg wants colorscheme applied
|
||||||
@ -147,7 +146,6 @@ class SvgPrivate
|
|||||||
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
q, SLOT(colorsChanged()));
|
q, SLOT(colorsChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (QFile::exists(imagePath)) {
|
} else if (QFile::exists(imagePath)) {
|
||||||
path = imagePath;
|
path = imagePath;
|
||||||
} else {
|
} else {
|
||||||
@ -157,7 +155,7 @@ class SvgPrivate
|
|||||||
//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
|
//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)) {
|
if (themed || QFile::exists(imagePath)) {
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
bool found = Theme::defaultTheme()->findInRectsCache(path, "_Natural", rect);
|
bool found = actualTheme()->findInRectsCache(path, "_Natural", rect);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
createRenderer();
|
createRenderer();
|
||||||
@ -171,6 +169,15 @@ class SvgPrivate
|
|||||||
return updateNeeded;
|
return updateNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Theme *actualTheme()
|
||||||
|
{
|
||||||
|
if (!theme) {
|
||||||
|
theme = Plasma::Theme::defaultTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap findInCache(const QString &elementId, const QSizeF &s = QSizeF())
|
QPixmap findInCache(const QString &elementId, const QSizeF &s = QSizeF())
|
||||||
{
|
{
|
||||||
QSize size;
|
QSize size;
|
||||||
@ -193,12 +200,14 @@ class SvgPrivate
|
|||||||
//kDebug() << "id is " << id;
|
//kDebug() << "id is " << id;
|
||||||
|
|
||||||
QPixmap p;
|
QPixmap p;
|
||||||
if (cacheRendering && const_cast<Theme*>(theme)->findInCache(id, p, lastModified)) {
|
if (cacheRendering) {
|
||||||
|
if (const_cast<Theme*>(actualTheme())->findInCache(id, p, lastModified)) {
|
||||||
//kDebug() << "found cached version of " << id << p.size();
|
//kDebug() << "found cached version of " << id << p.size();
|
||||||
return p;
|
return p;
|
||||||
} else {
|
|
||||||
//kDebug() << "didn't find cached version of " << id << ", so re-rendering";
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//kDebug() << "didn't find cached version of " << id << ", so re-rendering";
|
||||||
|
|
||||||
//kDebug() << "size for " << elementId << " is " << s;
|
//kDebug() << "size for " << elementId << " is " << s;
|
||||||
// we have to re-render this puppy
|
// we have to re-render this puppy
|
||||||
@ -220,7 +229,7 @@ class SvgPrivate
|
|||||||
// Apply current color scheme if the svg asks for it
|
// Apply current color scheme if the svg asks for it
|
||||||
if (applyColors) {
|
if (applyColors) {
|
||||||
QImage itmp = p.toImage();
|
QImage itmp = p.toImage();
|
||||||
KIconEffect::colorize(itmp, theme->color(Theme::BackgroundColor), 1.0);
|
KIconEffect::colorize(itmp, actualTheme()->color(Theme::BackgroundColor), 1.0);
|
||||||
p = p.fromImage(itmp);
|
p = p.fromImage(itmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +272,7 @@ class SvgPrivate
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
path = theme->imagePath(themePath);
|
path = actualTheme()->imagePath(themePath);
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
kWarning() << "No image path found for" << themePath;
|
kWarning() << "No image path found for" << themePath;
|
||||||
}
|
}
|
||||||
@ -297,8 +306,11 @@ class SvgPrivate
|
|||||||
if (renderer && renderer.count() == 2) {
|
if (renderer && renderer.count() == 2) {
|
||||||
// this and the cache reference it
|
// this and the cache reference it
|
||||||
s_renderers.erase(s_renderers.find(path));
|
s_renderers.erase(s_renderers.find(path));
|
||||||
|
|
||||||
|
if (theme) {
|
||||||
const_cast<Plasma::Theme *>(theme)->releaseRectsCache(path);
|
const_cast<Plasma::Theme *>(theme)->releaseRectsCache(path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderer = 0;
|
renderer = 0;
|
||||||
localRectCache.clear();
|
localRectCache.clear();
|
||||||
@ -307,7 +319,7 @@ class SvgPrivate
|
|||||||
QRectF elementRect(const QString &elementId)
|
QRectF elementRect(const QString &elementId)
|
||||||
{
|
{
|
||||||
if (themed && path.isEmpty()) {
|
if (themed && path.isEmpty()) {
|
||||||
path = theme->imagePath(themePath);
|
path = actualTheme()->imagePath(themePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString id = cacheId(elementId);
|
QString id = cacheId(elementId);
|
||||||
@ -316,7 +328,7 @@ class SvgPrivate
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
bool found = Theme::defaultTheme()->findInRectsCache(path, id, rect);
|
bool found = actualTheme()->findInRectsCache(path, id, rect);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
localRectCache.insert(id, rect);
|
localRectCache.insert(id, rect);
|
||||||
@ -354,7 +366,7 @@ class SvgPrivate
|
|||||||
void checkApplyColorHint()
|
void checkApplyColorHint()
|
||||||
{
|
{
|
||||||
QRectF elementRect;
|
QRectF elementRect;
|
||||||
bool found = Theme::defaultTheme()->findInRectsCache(themePath, cacheId("hint-apply-color-scheme"), elementRect);
|
bool found = actualTheme()->findInRectsCache(themePath, cacheId("hint-apply-color-scheme"), elementRect);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
applyColors = elementRect.isValid();
|
applyColors = elementRect.isValid();
|
||||||
@ -541,7 +553,7 @@ bool Svg::hasElement(const QString &elementId) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRectF elementRect;
|
QRectF elementRect;
|
||||||
bool found = Theme::defaultTheme()->findInRectsCache(d->path, id, elementRect);
|
bool found = d->actualTheme()->findInRectsCache(d->path, id, elementRect);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
d->localRectCache.insert(id, elementRect);
|
d->localRectCache.insert(id, elementRect);
|
||||||
@ -597,7 +609,6 @@ void Svg::setImagePath(const QString &svgFilePath)
|
|||||||
if (!d->themed) {
|
if (!d->themed) {
|
||||||
QFile f(svgFilePath);
|
QFile f(svgFilePath);
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
|
|
||||||
d->lastModified = info.lastModified().toTime_t();
|
d->lastModified = info.lastModified().toTime_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,12 +633,11 @@ bool Svg::isUsingRenderingCache() const
|
|||||||
|
|
||||||
void Svg::setTheme(const Plasma::Theme *theme)
|
void Svg::setTheme(const Plasma::Theme *theme)
|
||||||
{
|
{
|
||||||
if (!theme) {
|
if (d->theme) {
|
||||||
d->theme = Plasma::Theme::defaultTheme();
|
disconnect(d->theme, 0, this, 0);
|
||||||
} else {
|
|
||||||
d->theme = theme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->theme = theme;
|
||||||
setImagePath(imagePath());
|
setImagePath(imagePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user