Accepting request 1068360 from home:Vogtinator:plasma5.27

- Apply important fixes from the 5.27 branch:
  * 0001-Expose-FlatpakReferencesModel-to-QML.patch
  * 0002-Avoid-duplicating-connections-between-ref-and-its-re.patch
  * 0003-Port-from-NULL-to-nullptr.patch
  * 0004-Fix-GLib-memory-management-issue.patch

OBS-URL: https://build.opensuse.org/request/show/1068360
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/kcm_flatpak?expand=0&rev=9
This commit is contained in:
Christophe Marin 2023-03-01 10:36:31 +00:00 committed by Git OBS Bridge
parent 3c593ddb12
commit 71a78e011c
6 changed files with 183 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From 7315348966666340557f61bb0f25b3c9dc3a9f29 Mon Sep 17 00:00:00 2001
From: ivan tkachenko <me@ratijas.tk>
Date: Tue, 7 Feb 2023 03:01:38 +0300
Subject: [PATCH 1/4] Expose FlatpakReferencesModel to QML
We'll be needing its enum values soon, to request model data by role.
(cherry picked from commit fc64ff4b8cc2f285ca99dc9d311d299b66780a95)
This was actually required for 03f195ea353f0ca522e49aacc76eb74612d2d653.
---
flatpakreference.h | 1 +
kcm.cpp | 1 +
2 files changed, 2 insertions(+)
diff --git a/flatpakreference.h b/flatpakreference.h
index cc5d5e7..3a78878 100644
--- a/flatpakreference.h
+++ b/flatpakreference.h
@@ -66,6 +66,7 @@ public:
explicit FlatpakReferencesModel(QObject *parent = nullptr);
enum Roles { Name = Qt::UserRole + 1, Version, Icon, Ref };
+ Q_ENUM(Roles)
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
diff --git a/kcm.cpp b/kcm.cpp
index a98c9c5..0e2b16d 100644
--- a/kcm.cpp
+++ b/kcm.cpp
@@ -17,6 +17,7 @@ KCMFlatpak::KCMFlatpak(QObject *parent, const KPluginMetaData &data, const QVari
{
qmlRegisterUncreatableType<KCMFlatpak>("org.kde.plasma.kcm.flatpakpermissions", 1, 0, "KCMFlatpak", QString());
qmlRegisterType<FlatpakPermissionModel>("org.kde.plasma.kcm.flatpakpermissions", 1, 0, "FlatpakPermissionModel");
+ qmlRegisterUncreatableType<FlatpakReferencesModel>("org.kde.plasma.kcm.flatpakpermissions", 1, 0, "FlatpakReferencesModel", QStringLiteral("For enum access only"));
connect(m_refsModel, &FlatpakReferencesModel::needsLoad, this, &KCMFlatpak::load);
connect(m_refsModel, &FlatpakReferencesModel::needsSaveChanged, this, &KCMFlatpak::refreshSaveNeeded);
--
2.39.2

View File

@ -0,0 +1,55 @@
From d852e44cb5e4ff7b49ba91921517cd0679431c28 Mon Sep 17 00:00:00 2001
From: ivan tkachenko <me@ratijas.tk>
Date: Wed, 1 Mar 2023 01:20:15 +0300
Subject: [PATCH 2/4] Avoid duplicating connections between ref and its ref
model
These two connections should be established once in constructor, not on
every call to setter. Because every time when the setter is called, a
new connections are established which are not bound to the lifetime of
model object being set. But, the model object assigned is not managed
by this Ref object, and will be destroyed without any notice, most
importantly without calling setter with null argument which would be
the only way to clean up these extra connections.
Replaces https://invent.kde.org/plasma/flatpak-kcm/-/merge_requests/38
(cherry picked from commit b114d6e1e598c95ade68ef62c1a39ac32d38a29d)
---
flatpakreference.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/flatpakreference.cpp b/flatpakreference.cpp
index a2b5d71..d95f496 100644
--- a/flatpakreference.cpp
+++ b/flatpakreference.cpp
@@ -35,6 +35,9 @@ FlatpakReference::FlatpakReference(FlatpakReferencesModel *parent,
, m_refsModel(refsModel)
{
m_path.append(m_id);
+
+ connect(this, &FlatpakReference::needsLoad, parent, &FlatpakReferencesModel::needsLoad);
+ connect(this, &FlatpakReference::needsSaveChanged, parent, &FlatpakReferencesModel::needsSaveChanged);
}
QString FlatpakReference::name() const
@@ -78,16 +81,12 @@ void FlatpakReference::setPermsModel(FlatpakPermissionModel *permsModel)
if (permsModel != m_permsModel) {
if (m_permsModel) {
disconnect(m_permsModel, &FlatpakPermissionModel::referenceChanged, this, &FlatpakReference::needsLoad);
- disconnect(this, &FlatpakReference::needsLoad, m_refsModel, &FlatpakReferencesModel::needsLoad);
disconnect(m_permsModel, &FlatpakPermissionModel::dataChanged, this, &FlatpakReference::needsSaveChanged);
- disconnect(this, &FlatpakReference::needsSaveChanged, m_refsModel, &FlatpakReferencesModel::needsSaveChanged);
}
m_permsModel = permsModel;
if (m_permsModel) {
connect(m_permsModel, &FlatpakPermissionModel::referenceChanged, this, &FlatpakReference::needsLoad);
- connect(this, &FlatpakReference::needsLoad, m_refsModel, &FlatpakReferencesModel::needsLoad);
connect(m_permsModel, &FlatpakPermissionModel::dataChanged, this, &FlatpakReference::needsSaveChanged);
- connect(this, &FlatpakReference::needsSaveChanged, m_refsModel, &FlatpakReferencesModel::needsSaveChanged);
}
}
}
--
2.39.2

View File

@ -0,0 +1,41 @@
From b4ea85ce701b3cac3f9e997d9cb391a34ff4d4bc Mon Sep 17 00:00:00 2001
From: ivan tkachenko <me@ratijas.tk>
Date: Mon, 13 Feb 2023 23:38:13 +0300
Subject: [PATCH 3/4] Port from NULL to nullptr
(cherry picked from commit 6363d6fca26b357ac4c988fcfb0eda5069093926)
---
flatpakreference.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/flatpakreference.cpp b/flatpakreference.cpp
index d95f496..884a12f 100644
--- a/flatpakreference.cpp
+++ b/flatpakreference.cpp
@@ -131,10 +131,10 @@ bool FlatpakReference::isDefaults() const
FlatpakReferencesModel::FlatpakReferencesModel(QObject *parent)
: QAbstractListModel(parent)
{
- g_autoptr(FlatpakInstallation) installation = flatpak_installation_new_system(NULL, NULL);
- g_autoptr(GPtrArray) installedApps = flatpak_installation_list_installed_refs_by_kind(installation, FLATPAK_REF_KIND_APP, NULL, NULL);
- g_autoptr(FlatpakInstallation) userInstallation = flatpak_installation_new_user(NULL, NULL);
- g_autoptr(GPtrArray) installedUserApps = flatpak_installation_list_installed_refs_by_kind(userInstallation, FLATPAK_REF_KIND_APP, NULL, NULL);
+ g_autoptr(FlatpakInstallation) installation = flatpak_installation_new_system(nullptr, nullptr);
+ g_autoptr(GPtrArray) installedApps = flatpak_installation_list_installed_refs_by_kind(installation, FLATPAK_REF_KIND_APP, nullptr, nullptr);
+ g_autoptr(FlatpakInstallation) userInstallation = flatpak_installation_new_user(nullptr, nullptr);
+ g_autoptr(GPtrArray) installedUserApps = flatpak_installation_list_installed_refs_by_kind(userInstallation, FLATPAK_REF_KIND_APP, nullptr, nullptr);
g_ptr_array_extend_and_steal(installedApps, installedUserApps);
QString path = FlatpakHelper::permDataFilePath();
@@ -147,7 +147,7 @@ FlatpakReferencesModel::FlatpakReferencesModel(QObject *parent)
}
QString appBasePath = QString::fromUtf8(flatpak_installed_ref_get_deploy_dir(FLATPAK_INSTALLED_REF(g_ptr_array_index(installedApps, i))));
QString icon = FlatpakHelper::iconPath(name, id, appBasePath);
- g_autoptr(GBytes) data = flatpak_installed_ref_load_metadata(FLATPAK_INSTALLED_REF(g_ptr_array_index(installedApps, i)), NULL, NULL);
+ g_autoptr(GBytes) data = flatpak_installed_ref_load_metadata(FLATPAK_INSTALLED_REF(g_ptr_array_index(installedApps, i)), nullptr, nullptr);
gsize len = 0;
auto buff = g_bytes_get_data(data, &len);
const QByteArray metadata((const char *)buff, len);
--
2.39.2

View File

@ -0,0 +1,31 @@
From f0bf57cdb8436f357d0eedd3a306b9c9487f11cb Mon Sep 17 00:00:00 2001
From: ivan tkachenko <me@ratijas.tk>
Date: Wed, 1 Mar 2023 02:17:06 +0300
Subject: [PATCH 4/4] Fix GLib memory management issue
(process:81718): GLib-CRITICAL **: 03:12:47.357: g_atomic_ref_count_dec: assertion 'old_value > 0' failed
(cherry picked from commit 44edeeb14685e34ba1a3d3793d6d09fcbc8f8041)
---
flatpakreference.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/flatpakreference.cpp b/flatpakreference.cpp
index 884a12f..958efc5 100644
--- a/flatpakreference.cpp
+++ b/flatpakreference.cpp
@@ -134,8 +134,10 @@ FlatpakReferencesModel::FlatpakReferencesModel(QObject *parent)
g_autoptr(FlatpakInstallation) installation = flatpak_installation_new_system(nullptr, nullptr);
g_autoptr(GPtrArray) installedApps = flatpak_installation_list_installed_refs_by_kind(installation, FLATPAK_REF_KIND_APP, nullptr, nullptr);
g_autoptr(FlatpakInstallation) userInstallation = flatpak_installation_new_user(nullptr, nullptr);
- g_autoptr(GPtrArray) installedUserApps = flatpak_installation_list_installed_refs_by_kind(userInstallation, FLATPAK_REF_KIND_APP, nullptr, nullptr);
+ // it's the only pointer, so extend_and_steal will destroy it.
+ GPtrArray *installedUserApps = flatpak_installation_list_installed_refs_by_kind(userInstallation, FLATPAK_REF_KIND_APP, nullptr, nullptr);
g_ptr_array_extend_and_steal(installedApps, installedUserApps);
+ installedUserApps = nullptr;
QString path = FlatpakHelper::permDataFilePath();
for (uint i = 0; i < installedApps->len; ++i) {
--
2.39.2

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Mar 1 07:47:56 UTC 2023 - Fabian Vogt <fabian@ritter-vogt.de>
- Apply important fixes from the 5.27 branch:
* 0001-Expose-FlatpakReferencesModel-to-QML.patch
* 0002-Avoid-duplicating-connections-between-ref-and-its-re.patch
* 0003-Port-from-NULL-to-nullptr.patch
* 0004-Fix-GLib-memory-management-issue.patch
-------------------------------------------------------------------
Tue Feb 28 17:34:14 UTC 2023 - Fabian Vogt <fabian@ritter-vogt.de>

View File

@ -31,6 +31,11 @@ Source: https://download.kde.org/stable/plasma/%{version}/flatpak-kcm-%{
Source1: https://download.kde.org/stable/plasma/%{version}/flatpak-kcm-%{version}.tar.xz.sig
Source2: plasma.keyring
%endif
# PATCH-FIX-UPSTREAM
Patch1: 0001-Expose-FlatpakReferencesModel-to-QML.patch
Patch2: 0002-Avoid-duplicating-connections-between-ref-and-its-re.patch
Patch3: 0003-Port-from-NULL-to-nullptr.patch
Patch4: 0004-Fix-GLib-memory-management-issue.patch
BuildRequires: extra-cmake-modules >= 5.98.0
BuildRequires: kf5-filesystem
BuildRequires: pkgconfig