summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2021-11-30 15:41:13 +0100
committerAndreas Sturmlechner <asturm@gentoo.org>2021-12-08 16:07:45 +0100
commite1e08d9dff006c37492c3781ffe75dcd27e1df46 (patch)
tree9b5b79713a9aed031d4c4d53caba9dbbe158a4e7 /kde-frameworks/plasma
parentkde-frameworks/kio: Drop 5.88.0-r1 (diff)
downloadgentoo-e1e08d9dff006c37492c3781ffe75dcd27e1df46.tar.gz
gentoo-e1e08d9dff006c37492c3781ffe75dcd27e1df46.tar.bz2
gentoo-e1e08d9dff006c37492c3781ffe75dcd27e1df46.zip
kde-frameworks/plasma: Reload shared renderers if file changed on disk
Upstream commit fe9e118ff2212d48a0ea5fcc0346d6312978f3ed KDE-bug: https://bugs.kde.org/show_bug.cgi?id=445516 Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-frameworks/plasma')
-rw-r--r--kde-frameworks/plasma/files/plasma-5.88.0-reload-shared-renderers-if-changed-on-disk.patch269
-rw-r--r--kde-frameworks/plasma/plasma-5.88.0-r2.ebuild80
2 files changed, 349 insertions, 0 deletions
diff --git a/kde-frameworks/plasma/files/plasma-5.88.0-reload-shared-renderers-if-changed-on-disk.patch b/kde-frameworks/plasma/files/plasma-5.88.0-reload-shared-renderers-if-changed-on-disk.patch
new file mode 100644
index 000000000000..07d25c836bbf
--- /dev/null
+++ b/kde-frameworks/plasma/files/plasma-5.88.0-reload-shared-renderers-if-changed-on-disk.patch
@@ -0,0 +1,269 @@
+From fe9e118ff2212d48a0ea5fcc0346d6312978f3ed Mon Sep 17 00:00:00 2001
+From: Marco Martin <notmart@gmail.com>
+Date: Mon, 29 Nov 2021 14:40:38 +0000
+Subject: [PATCH] Reload shared renderers when a file changed on disk
+
+When we have to render a new pixmap, compare the file date with the date of the last time the file was cached. if the dates are different (not only older, in order to allow downgrades) then force the svg renderer to be reloaded from the new file, otherwise the renderer with the old file still loaded will save in cache old graphics with the id derived from the date of the new file, causing a wrong cache entry
+
+BUG:445516
+---
+ src/plasma/private/svg_p.h | 15 +++++-
+ src/plasma/svg.cpp | 100 +++++++++++++++++++++++++++----------
+ 2 files changed, 86 insertions(+), 29 deletions(-)
+
+diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h
+index 11b68f21c..d39f274b4 100644
+--- a/src/plasma/private/svg_p.h
++++ b/src/plasma/private/svg_p.h
+@@ -30,8 +30,14 @@ public:
+
+ SharedSvgRenderer(const QByteArray &contents, const QString &styleSheet, QHash<QString, QRectF> &interestingElements, QObject *parent = nullptr);
+
++ void reload();
++
+ private:
+ bool load(const QByteArray &contents, const QString &styleSheet, QHash<QString, QRectF> &interestingElements);
++
++ QString m_filename;
++ QString m_styleSheet;
++ QHash<QString, QRectF> m_interestingElements;
+ };
+
+ class SvgPrivate
+@@ -125,9 +131,8 @@ public:
+ bool findElementRect(SvgPrivate::CacheId cacheId, QRectF &rect);
+ bool findElementRect(uint id, const QString &filePath, QRectF &rect);
+
+- void loadImageFromCache(const QString &path, uint lastModified);
++ bool loadImageFromCache(const QString &path, uint lastModified);
+ void dropImageFromCache(const QString &path);
+- void expireCache(const QString &path);
+
+ void setNaturalSize(const QString &path, qreal scaleFactor, const QSizeF &size);
+ QSizeF naturalSize(const QString &path, qreal scaleFactor);
+@@ -140,10 +145,15 @@ public:
+
+ QStringList cachedKeysForPath(const QString &path) const;
+
++ unsigned int lastModifiedTimeFromCache(const QString &filePath);
++
+ void updateLastModified(const QString &filePath, unsigned int lastModified);
+
+ static const uint s_seed;
+
++Q_SIGNALS:
++ void lastModifiedChanged(const QString &filePath, unsigned int lastModified);
++
+ private:
+ QTimer *m_configSyncTimer = nullptr;
+ QString m_iconThemePath;
+@@ -156,6 +166,7 @@ private:
+ QHash<uint, QRectF> m_localRectCache;
+ QHash<QString, QSet<unsigned int>> m_invalidElements;
+ QHash<QString, QList<QSize>> m_sizeHintsForId;
++ QHash<QString, unsigned int> m_lastModifiedTimes;
+ };
+ }
+
+diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp
+index 1749381b7..47cf142e1 100644
+--- a/src/plasma/svg.cpp
++++ b/src/plasma/svg.cpp
+@@ -73,6 +73,9 @@ SharedSvgRenderer::SharedSvgRenderer(const QString &filename, const QString &sty
+ if (!file.open(QIODevice::ReadOnly)) {
+ return;
+ }
++ m_filename = filename;
++ m_styleSheet = styleSheet;
++ m_interestingElements = interestingElements;
+ load(file.readAll(), styleSheet, interestingElements);
+ }
+
+@@ -82,6 +85,16 @@ SharedSvgRenderer::SharedSvgRenderer(const QByteArray &contents, const QString &
+ load(contents, styleSheet, interestingElements);
+ }
+
++void SharedSvgRenderer::reload()
++{
++ KCompressionDevice file(m_filename, KCompressionDevice::GZip);
++ if (!file.open(QIODevice::ReadOnly)) {
++ return;
++ }
++
++ load(file.readAll(), m_styleSheet, m_interestingElements);
++}
++
+ bool SharedSvgRenderer::load(const QByteArray &contents, const QString &styleSheet, QHash<QString, QRectF> &interestingElements)
+ {
+ // Apply the style sheet.
+@@ -161,21 +174,31 @@ void SvgRectsCache::insert(Plasma::SvgPrivate::CacheId cacheId, const QRectF &re
+
+ void SvgRectsCache::insert(uint id, const QString &filePath, const QRectF &rect, unsigned int lastModified)
+ {
+- if (m_localRectCache.contains(id)) {
++ const unsigned int savedTime = lastModifiedTimeFromCache(filePath);
++
++ if (savedTime == lastModified && m_localRectCache.contains(id)) {
+ return;
+ }
+
+ m_localRectCache.insert(id, rect);
+
++
+ KConfigGroup imageGroup(m_svgElementsCache, filePath);
+- imageGroup.writeEntry("LastModified", lastModified);
++
+ if (rect.isValid()) {
+ imageGroup.writeEntry(QString::number(id), rect);
+ } else {
+ m_invalidElements[filePath] << id;
+ imageGroup.writeEntry("Invalidelements", m_invalidElements[filePath].values());
+ }
++
+ QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
++
++ if (savedTime != lastModified) {
++ m_lastModifiedTimes[filePath] = lastModified;
++ imageGroup.writeEntry("LastModified", lastModified);
++ Q_EMIT lastModifiedChanged(filePath, lastModified);
++ }
+ }
+
+ bool SvgRectsCache::findElementRect(Plasma::SvgPrivate::CacheId cacheId, QRectF &rect)
+@@ -201,20 +224,21 @@ bool SvgRectsCache::findElementRect(uint id, const QString &filePath, QRectF &re
+ return true;
+ }
+
+-void SvgRectsCache::loadImageFromCache(const QString &path, uint lastModified)
++bool SvgRectsCache::loadImageFromCache(const QString &path, uint lastModified)
+ {
+ if (path.isEmpty()) {
+- return;
++ return false;
+ }
+
+ KConfigGroup imageGroup(m_svgElementsCache, path);
+
+- unsigned int savedTime = imageGroup.readEntry("LastModified", 0);
++ unsigned int savedTime = lastModifiedTimeFromCache(path);
+
+- if (lastModified > savedTime) {
++ // Reload even if is older, to support downgrades
++ if (lastModified != savedTime) {
+ imageGroup.deleteGroup();
+ QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
+- return;
++ return false;
+ }
+
+ auto &elements = m_invalidElements[path];
+@@ -231,6 +255,7 @@ void SvgRectsCache::loadImageFromCache(const QString &path, uint lastModified)
+ }
+ }
+ }
++ return true;
+ }
+
+ void SvgRectsCache::dropImageFromCache(const QString &path)
+@@ -302,22 +327,6 @@ void SvgRectsCache::setIconThemePath(const QString &path)
+ QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
+ }
+
+-void SvgRectsCache::expireCache(const QString &path)
+-{
+- KConfigGroup imageGroup(m_svgElementsCache, path);
+-
+- unsigned int savedTime = imageGroup.readEntry("LastModified", QDateTime().toSecsSinceEpoch());
+- QFileInfo info(path);
+- if (info.exists()) {
+- unsigned int lastModified = info.lastModified().toSecsSinceEpoch();
+- if (lastModified <= savedTime) {
+- return;
+- }
+- }
+-
+- imageGroup.deleteGroup();
+-}
+-
+ void SvgRectsCache::setNaturalSize(const QString &path, qreal scaleFactor, const QSizeF &size)
+ {
+ KConfigGroup imageGroup(m_svgElementsCache, path);
+@@ -349,11 +358,30 @@ QStringList SvgRectsCache::cachedKeysForPath(const QString &path) const
+ return filtered;
+ }
+
++unsigned int SvgRectsCache::lastModifiedTimeFromCache(const QString &filePath)
++{
++ const auto &i = m_lastModifiedTimes.constFind(filePath);
++ if (i != m_lastModifiedTimes.constEnd()) {
++ return i.value();
++ }
++
++ KConfigGroup imageGroup(m_svgElementsCache, filePath);
++ const unsigned int savedTime = imageGroup.readEntry("LastModified", 0);
++ m_lastModifiedTimes[filePath] = savedTime;
++ return savedTime;
++}
++
+ void SvgRectsCache::updateLastModified(const QString &filePath, unsigned int lastModified)
+ {
+ KConfigGroup imageGroup(m_svgElementsCache, filePath);
+- imageGroup.writeEntry("LastModified", lastModified);
+- QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
++ const unsigned int savedTime = lastModifiedTimeFromCache(filePath);
++
++ if (savedTime != lastModified) {
++ m_lastModifiedTimes[filePath] = lastModified;
++ imageGroup.writeEntry("LastModified", lastModified);
++ QMetaObject::invokeMethod(m_configSyncTimer, qOverload<>(&QTimer::start));
++ Q_EMIT lastModifiedChanged(filePath, lastModified);
++ }
+ }
+
+ SvgPrivate::SvgPrivate(Svg *svg)
+@@ -463,7 +491,17 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
+
+ lastModified = lastModifiedDate.toSecsSinceEpoch();
+
+- SvgRectsCache::instance()->loadImageFromCache(path, lastModified);
++ const bool imageWasCached = SvgRectsCache::instance()->loadImageFromCache(path, lastModified);
++
++ if (!imageWasCached) {
++ auto i = s_renderers.constBegin();
++ while (i != s_renderers.constEnd()) {
++ if (i.key().contains(path)) {
++ i.value()->reload();
++ }
++ i++;
++ }
++ }
+
+ // check if svg wants colorscheme applied
+ checkColorHints();
+@@ -552,7 +590,8 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
+ const QString id = cachePath(actualElementId, size);
+
+ QPixmap p;
+- if (cacheRendering && cacheAndColorsTheme()->findInCache(id, p, lastModified)) {
++ if (cacheRendering && lastModified == SvgRectsCache::instance()->lastModifiedTimeFromCache(path)
++ && cacheAndColorsTheme()->findInCache(id, p, lastModified)) {
+ p.setDevicePixelRatio(ratio);
+ // qCDebug(LOG_PLASMA) << "found cached version of " << id << p.size();
+ return p;
+@@ -845,6 +884,13 @@ Svg::Svg(QObject *parent)
+ : QObject(parent)
+ , d(new SvgPrivate(this))
+ {
++ connect(SvgRectsCache::instance(), &SvgRectsCache::lastModifiedChanged,
++ this, [this] (const QString &filePath, unsigned int lastModified) {
++ if (d->lastModified != lastModified && filePath == d->path) {
++ d->lastModified = lastModified;
++ Q_EMIT repaintNeeded();
++ }
++ });
+ }
+
+ Svg::~Svg()
+--
+GitLab
+
diff --git a/kde-frameworks/plasma/plasma-5.88.0-r2.ebuild b/kde-frameworks/plasma/plasma-5.88.0-r2.ebuild
new file mode 100644
index 000000000000..8cf6ee9309bb
--- /dev/null
+++ b/kde-frameworks/plasma/plasma-5.88.0-r2.ebuild
@@ -0,0 +1,80 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+KDE_ORG_NAME="${PN}-framework"
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.15.2
+VIRTUALX_REQUIRED="test"
+inherit ecm kde.org
+
+DESCRIPTION="Plasma framework"
+
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
+IUSE="gles2-only man wayland X"
+
+RESTRICT="test"
+
+RDEPEND="
+ >=dev-qt/qtdbus-${QTMIN}:5
+ >=dev-qt/qtdeclarative-${QTMIN}:5
+ >=dev-qt/qtgui-${QTMIN}:5[gles2-only=,X=]
+ >=dev-qt/qtquickcontrols-${QTMIN}:5
+ >=dev-qt/qtsql-${QTMIN}:5
+ >=dev-qt/qtsvg-${QTMIN}:5
+ >=dev-qt/qtwidgets-${QTMIN}:5
+ =kde-frameworks/kactivities-${PVCUT}*:5
+ =kde-frameworks/karchive-${PVCUT}*:5
+ =kde-frameworks/kconfig-${PVCUT}*:5
+ =kde-frameworks/kconfigwidgets-${PVCUT}*:5
+ =kde-frameworks/kcoreaddons-${PVCUT}*:5
+ =kde-frameworks/kdeclarative-${PVCUT}*:5
+ =kde-frameworks/kglobalaccel-${PVCUT}*:5
+ =kde-frameworks/kguiaddons-${PVCUT}*:5
+ =kde-frameworks/ki18n-${PVCUT}*:5
+ =kde-frameworks/kiconthemes-${PVCUT}*:5
+ =kde-frameworks/kio-${PVCUT}*:5
+ =kde-frameworks/kirigami-${PVCUT}*:5
+ =kde-frameworks/knotifications-${PVCUT}*:5
+ =kde-frameworks/kpackage-${PVCUT}*:5
+ =kde-frameworks/kservice-${PVCUT}*:5
+ =kde-frameworks/kwidgetsaddons-${PVCUT}*:5
+ =kde-frameworks/kwindowsystem-${PVCUT}*:5
+ =kde-frameworks/kxmlgui-${PVCUT}*:5
+ !gles2-only? ( media-libs/libglvnd[X?] )
+ wayland? (
+ =kde-frameworks/kwayland-${PVCUT}*:5
+ media-libs/libglvnd
+ )
+ X? (
+ >=dev-qt/qtx11extras-${QTMIN}:5
+ x11-libs/libX11
+ x11-libs/libxcb
+ )
+"
+DEPEND="${RDEPEND}
+ X? ( x11-base/xorg-proto )
+"
+BDEPEND="man? ( >=kde-frameworks/kdoctools-${PVCUT}:5 )"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-make-OSD-an-actual-wayland-OSD.patch
+ "${FILESDIR}"/${P}-fix-misrenderings-with-transparency.patch # KDE-bug 305247
+ "${FILESDIR}"/${P}-fix-centered-text.patch # KDE-bug 442830
+ "${FILESDIR}"/${P}-reload-shared-renderers-if-changed-on-disk.patch # KDE-bug 445516
+)
+
+src_configure() {
+ local mycmakeargs=(
+ $(cmake_use_find_package !gles2-only OpenGL)
+ $(cmake_use_find_package man KF5DocTools)
+ $(cmake_use_find_package wayland EGL)
+ $(cmake_use_find_package wayland KF5Wayland)
+ $(cmake_use_find_package X X11)
+ $(cmake_use_find_package X XCB)
+ )
+
+ ecm_src_configure
+}