Deprecate a lastModified timestamp of 0 in Theme::findInCache
lastModified is used to track whether a file is outdated. Having a 0 here means we (in the old code) use the cached version. This causes problems when the on-disk file has changed, as we have no way of informing callers that they should regenerate the cache entry. To avoid this, using a lastModified of 0 now warns and will always return false (to indicate it is not cached). Unfortunately we can't simply drop the default parameter of 0 since there is no source-compatible way of doing that. CCBUG: 426674
This commit is contained in:
parent
c0ebacfa68
commit
54e12fcda0
@ -282,23 +282,31 @@ bool Theme::useGlobalSettings() const
|
|||||||
|
|
||||||
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
||||||
{
|
{
|
||||||
if (lastModified != 0 && d->useCache() && lastModified > uint(d->pixmapCache->lastModifiedTime().toSecsSinceEpoch())) {
|
//TODO KF6: Make lastModified non-optional.
|
||||||
|
if (lastModified == 0) {
|
||||||
|
qCWarning(LOG_PLASMA) << "findInCache with a lastModified timestamp of 0 is deprecated";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->useCache()) {
|
if (!d->useCache()) {
|
||||||
const QString id = d->keysToCache.value(key);
|
return false;
|
||||||
const auto it = d->pixmapsToCache.constFind(id);
|
}
|
||||||
if (it != d->pixmapsToCache.constEnd()) {
|
|
||||||
pix = *it;
|
|
||||||
return !pix.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap temp;
|
if (lastModified > uint(d->pixmapCache->lastModifiedTime().toSecsSinceEpoch())) {
|
||||||
if (d->pixmapCache->findPixmap(key, &temp) && !temp.isNull()) {
|
return false;
|
||||||
pix = temp;
|
}
|
||||||
return true;
|
|
||||||
}
|
const QString id = d->keysToCache.value(key);
|
||||||
|
const auto it = d->pixmapsToCache.constFind(id);
|
||||||
|
if (it != d->pixmapsToCache.constEnd()) {
|
||||||
|
pix = *it;
|
||||||
|
return !pix.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap temp;
|
||||||
|
if (d->pixmapCache->findPixmap(key, &temp) && !temp.isNull()) {
|
||||||
|
pix = temp;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -220,6 +220,10 @@ public:
|
|||||||
* @param lastModified if non-zero, the time stamp is also checked on the file,
|
* @param lastModified if non-zero, the time stamp is also checked on the file,
|
||||||
* and must be newer than the timestamp to be loaded
|
* and must be newer than the timestamp to be loaded
|
||||||
*
|
*
|
||||||
|
* @note Since KF 5.75, a lastModified value of 0 is deprecated. If used, it
|
||||||
|
* will now always return false. Use a proper file timestamp instead
|
||||||
|
* so modification can be properly tracked.
|
||||||
|
*
|
||||||
* @return true when pixmap was found and loaded from cache, false otherwise
|
* @return true when pixmap was found and loaded from cache, false otherwise
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
**/
|
**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user