public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/plasma/, kde-frameworks/plasma/files/
Date: Wed,  8 Dec 2021 15:08:24 +0000 (UTC)	[thread overview]
Message-ID: <1638976065.e1e08d9dff006c37492c3781ffe75dcd27e1df46.asturm@gentoo> (raw)

commit:     e1e08d9dff006c37492c3781ffe75dcd27e1df46
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 30 14:41:13 2021 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed Dec  8 15:07:45 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e1e08d9d

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 <AT> gentoo.org>

 ...eload-shared-renderers-if-changed-on-disk.patch | 269 +++++++++++++++++++++
 kde-frameworks/plasma/plasma-5.88.0-r2.ebuild      |  80 ++++++
 2 files changed, 349 insertions(+)

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
+}


             reply	other threads:[~2021-12-08 15:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 15:08 Andreas Sturmlechner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-01 19:46 [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/plasma/, kde-frameworks/plasma/files/ Andreas Sturmlechner
2023-01-29  0:12 Andreas Sturmlechner
2022-11-27 11:20 Andreas Sturmlechner
2022-08-06  7:44 Andreas Sturmlechner
2022-07-26 12:08 Andreas Sturmlechner
2022-06-14 12:44 Andreas Sturmlechner
2022-04-21  8:56 Andreas Sturmlechner
2022-04-15 18:27 Andreas Sturmlechner
2022-03-30 14:41 Andreas Sturmlechner
2022-02-10  9:13 Andreas Sturmlechner
2021-11-23 14:59 Andreas Sturmlechner
2021-10-11 11:01 Andreas Sturmlechner
2021-09-30 17:24 Andreas Sturmlechner
2021-08-26 17:28 Andreas Sturmlechner
2021-08-15 18:57 Andreas Sturmlechner
2021-08-15 18:57 Andreas Sturmlechner
2021-01-11 12:28 Andreas Sturmlechner
2020-11-16 23:41 Andreas Sturmlechner
2020-10-26 19:06 Andreas Sturmlechner
2020-04-17 20:59 Andreas Sturmlechner
2020-02-13 23:20 Andreas Sturmlechner
2019-03-13 11:05 Andreas Sturmlechner
2017-04-15 20:31 Andreas Sturmlechner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1638976065.e1e08d9dff006c37492c3781ffe75dcd27e1df46.asturm@gentoo \
    --to=asturm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox