Commit 72239e7f authored by Marco Martin's avatar Marco Martin
Browse files

apps can use more than one theme.

add the name in s_sharedFrames
CCBUG:335003
CCBUG:335004
parent bbed0411
......@@ -70,7 +70,7 @@ void FrameSvg::setImagePath(const QString &path)
if (fd->refcount() == 1) {
// we're the only user of it, let's remove it from the shared keys
// we don't want to deref it, however, as we'll still be using it
const QString oldKey = d->cacheId(fd, d->prefix);
const QString oldKey = theme()->themeName() + "_" + d->cacheId(fd, d->prefix);
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
} else {
// others are using this frame, so deref it for ourselves
......@@ -83,7 +83,7 @@ void FrameSvg::setImagePath(const QString &path)
if (!fd) {
// we need to replace our frame, start by looking in the frame cache
FrameData *oldFd = d->frames[d->prefix];
const QString key = d->cacheId(oldFd, d->prefix);
const QString key = theme()->themeName() + "_" + d->cacheId(oldFd, d->prefix);
fd = FrameSvgPrivate::s_sharedFrames.value(key);
if (fd) {
......@@ -104,7 +104,7 @@ void FrameSvg::setImagePath(const QString &path)
setContainsMultipleImages(true);
if (updateNeeded) {
// ensure our frame is in the cache
const QString key = d->cacheId(fd, d->prefix);
const QString key = theme()->themeName() + "_" + d->cacheId(fd, d->prefix);
FrameSvgPrivate::s_sharedFrames.insert(key, fd);
// this will emit repaintNeeded() as well when it is done
......@@ -129,7 +129,7 @@ void FrameSvg::setEnabledBorders(const EnabledBorders borders)
fd->enabledBorders = oldBorders;
//qDebug() << "looking for" << newKey;
FrameData *newFd = FrameSvgPrivate::s_sharedFrames.value(newKey);
FrameData *newFd = FrameSvgPrivate::s_sharedFrames.value(theme()->themeName() + "_" + newKey);
if (newFd) {
//qDebug() << "FOUND IT!" << newFd->refcount;
// we've found a math, so insert that new one and ref it ..
......@@ -140,7 +140,7 @@ void FrameSvg::setEnabledBorders(const EnabledBorders borders)
if (fd->deref(this)) {
//const QString oldKey = d->cacheId(fd, d->prefix);
//qDebug() << "1. Removing it" << oldKey << fd->refcount;
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
FrameSvgPrivate::s_sharedFrames.remove(theme()->themeName() + "_" + oldKey);
delete fd;
}
......@@ -150,7 +150,7 @@ void FrameSvg::setEnabledBorders(const EnabledBorders borders)
if (fd->refcount() == 1) {
// we're the only user of it, let's remove it from the shared keys
// we don't want to deref it, however, as we'll still be using it
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
FrameSvgPrivate::s_sharedFrames.remove(theme()->themeName() + "_" + oldKey);
} else {
// others are using it, but we wish to change its size. so deref it,
// then create a copy of it (we're automatically ref'd via the ctor),
......@@ -224,7 +224,7 @@ void FrameSvg::setElementPrefix(const QString &prefix)
if (oldFrameData) {
FrameData *newFd = 0;
if (!oldFrameData->frameSize.isEmpty()) {
const QString key = d->cacheId(oldFrameData, d->prefix);
const QString key = theme()->themeName() + "_" + d->cacheId(oldFrameData, d->prefix);
newFd = FrameSvgPrivate::s_sharedFrames.value(key);
}
......@@ -242,7 +242,7 @@ void FrameSvg::setElementPrefix(const QString &prefix)
if (cache) {
// we have to cache after inserting the frame since the cacheId requires the
// frame to be in the frames collection already
const QString key = d->cacheId(oldFrameData, d->prefix);
const QString key = theme()->themeName() + "_" + d->cacheId(oldFrameData, d->prefix);
//qDebug() << this << " 1. inserting as" << key;
FrameSvgPrivate::s_sharedFrames.insert(key, newFd);
......@@ -261,7 +261,7 @@ void FrameSvg::setElementPrefix(const QString &prefix)
d->frames.remove(oldPrefix);
if (oldFrameData) {
if (oldFrameData->deref(this)) {
const QString oldKey = d->cacheId(oldFrameData, oldPrefix);
const QString oldKey = theme()->themeName() + "_" + d->cacheId(oldFrameData, oldPrefix);
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
delete oldFrameData;
}
......@@ -337,7 +337,7 @@ void FrameSvg::resizeFrame(const QSizeF &size)
fd->frameSize = currentSize;
//qDebug() << "looking for" << newKey;
FrameData *newFd = FrameSvgPrivate::s_sharedFrames.value(newKey);
FrameData *newFd = FrameSvgPrivate::s_sharedFrames.value(theme()->themeName() + "_" + newKey);
if (newFd) {
//qDebug() << "FOUND IT!" << newFd->refcount;
// we've found a math, so insert that new one and ref it ..
......@@ -348,7 +348,7 @@ void FrameSvg::resizeFrame(const QSizeF &size)
if (fd->deref(this)) {
//const QString oldKey = d->cacheId(fd, d->prefix);
//qDebug() << "1. Removing it" << oldKey << fd->refcount;
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
FrameSvgPrivate::s_sharedFrames.remove(theme()->themeName() + "_" + oldKey);
delete fd;
}
......@@ -358,7 +358,7 @@ void FrameSvg::resizeFrame(const QSizeF &size)
if (fd->refcount() == 1) {
// we're the only user of it, let's remove it from the shared keys
// we don't want to deref it, however, as we'll still be using it
FrameSvgPrivate::s_sharedFrames.remove(oldKey);
FrameSvgPrivate::s_sharedFrames.remove(theme()->themeName() + "_" + oldKey);
} else {
// others are using it, but we wish to change its size. so deref it,
// then create a copy of it (we're automatically ref'd via the ctor),
......@@ -371,7 +371,7 @@ void FrameSvg::resizeFrame(const QSizeF &size)
d->updateSizes();
fd->frameSize = size.toSize();
// we know it isn't in s_sharedFrames due to the check above, so insert it now
FrameSvgPrivate::s_sharedFrames.insert(newKey, fd);
FrameSvgPrivate::s_sharedFrames.insert(theme()->themeName() + "_" + newKey, fd);
}
QSizeF FrameSvg::frameSize() const
......@@ -527,7 +527,7 @@ void FrameSvg::clearCache()
if (frame != p) {
//TODO: should we clear from the Theme pixmap cache as well?
if (p->deref(this)) {
const QString key = d->cacheId(p, it.key());
const QString key = theme()->themeName() + "_" + d->cacheId(p, it.key());
FrameSvgPrivate::s_sharedFrames.remove(key);
p->cachedBackground = QPixmap();
}
......@@ -595,10 +595,10 @@ FrameSvgPrivate::~FrameSvgPrivate()
const QString key = cacheId(it.value(), it.key());
#ifdef DEBUG_FRAMESVG_CACHE
#ifndef NDEBUG
// qDebug() << "2. Removing it" << key << it.value() << it.value()->refcount() << s_sharedFrames.contains(key);
// qDebug() << "2. Removing it" << key << it.value() << it.value()->refcount() << s_sharedFrames.contains(theme()->themeName() + "_" + key);
#endif
#endif
s_sharedFrames.remove(key);
s_sharedFrames.remove(q->theme()->themeName() + "_" + key);
delete it.value();
}
#ifdef DEBUG_FRAMESVG_CACHE
......@@ -671,7 +671,7 @@ QPixmap FrameSvgPrivate::alphaMask()
prefix = maskPrefix % oldPrefix;
if (!frames.contains(prefix)) {
const QString key = cacheId(frame, prefix);
const QString key = q->theme()->themeName() + "_" + cacheId(frame, prefix);
// see if we can find a suitable candidate in the shared frames
// if successful, ref and insert, otherwise create a new one
// and insert that into both the shared frames and our frames.
......@@ -681,7 +681,7 @@ QPixmap FrameSvgPrivate::alphaMask()
maskFrame->ref(q);
} else {
maskFrame = new FrameData(*frame, q);
s_sharedFrames.insert(key, maskFrame);
s_sharedFrames.insert(q->theme()->themeName() + "_" + key, maskFrame);
}
frames.insert(prefix, maskFrame);
......@@ -693,9 +693,9 @@ QPixmap FrameSvgPrivate::alphaMask()
const QString oldKey = cacheId(maskFrame, prefix);
maskFrame->frameSize = frameSize(frame).toSize();
const QString newKey = cacheId(maskFrame, prefix);
if (s_sharedFrames.contains(oldKey)) {
s_sharedFrames.remove(oldKey);
s_sharedFrames.insert(newKey, maskFrame);
if (s_sharedFrames.contains(q->theme()->themeName() + "_" + oldKey)) {
s_sharedFrames.remove(q->theme()->themeName() + "_" + oldKey);
s_sharedFrames.insert(q->theme()->themeName() + "_" + newKey, maskFrame);
}
maskFrame->cachedBackground = QPixmap();
......
......@@ -80,7 +80,7 @@ Theme::Theme(const QString &themeName, QObject *parent)
// turn off caching so we don't accidently trigger unnecessary disk activity at this point
bool useCache = d->cacheTheme;
d->cacheTheme = false;
d->setThemeName(themeName, true);
d->setThemeName(themeName, false);
d->cacheTheme = useCache;
if (QCoreApplication::instance()) {
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment