summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2023-01-28 22:45:47 +0100
committerAndreas Sturmlechner <asturm@gentoo.org>2023-01-28 23:32:26 +0100
commit93ce4f04790e887e14d4176fe1f931e07f9c31aa (patch)
treed4638847c9d50443299e45754822fe8d29654c45 /kde-apps/libkgapi
parentkde-apps/kmailtransport: SmtpJob: Fix use of KCompositeJob (diff)
downloadgentoo-93ce4f04790e887e14d4176fe1f931e07f9c31aa.tar.gz
gentoo-93ce4f04790e887e14d4176fe1f931e07f9c31aa.tar.bz2
gentoo-93ce4f04790e887e14d4176fe1f931e07f9c31aa.zip
kde-apps/libkgapi: Fix AccountManager promises cache handling
Upstream commits: b5a581d98d9b57363c44bd98eeab7243fbf13a22 d677a08c21fd99e7e8be0a0899f797f9237207e4 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=406839 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=409122 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=421664 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=456923 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-apps/libkgapi')
-rw-r--r--kde-apps/libkgapi/files/libkgapi-22.08.3-AccountManager-dont-keep-finished-promises-in-cache.patch27
-rw-r--r--kde-apps/libkgapi/files/libkgapi-22.08.3-dont-cache-promises-for-AccountManager-findAccount.patch75
-rw-r--r--kde-apps/libkgapi/libkgapi-22.08.3-r1.ebuild49
3 files changed, 151 insertions, 0 deletions
diff --git a/kde-apps/libkgapi/files/libkgapi-22.08.3-AccountManager-dont-keep-finished-promises-in-cache.patch b/kde-apps/libkgapi/files/libkgapi-22.08.3-AccountManager-dont-keep-finished-promises-in-cache.patch
new file mode 100644
index 000000000000..485bc7d840f8
--- /dev/null
+++ b/kde-apps/libkgapi/files/libkgapi-22.08.3-AccountManager-dont-keep-finished-promises-in-cache.patch
@@ -0,0 +1,27 @@
+From b5a581d98d9b57363c44bd98eeab7243fbf13a22 Mon Sep 17 00:00:00 2001
+From: Fabian Vogt <fabian@ritter-vogt.de>
+Date: Mon, 21 Nov 2022 13:00:41 +0100
+Subject: [PATCH] AccountManager: Don't keep finished promises in the cache
+
+AccountPromises are destroyed one event loop cycle after they finished().
+They won't emit finished() again, so they can't be used.
+---
+ src/core/accountmanager.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/core/accountmanager.cpp b/src/core/accountmanager.cpp
+index 42719c5e..da5c37b6 100644
+--- a/src/core/accountmanager.cpp
++++ b/src/core/accountmanager.cpp
+@@ -134,7 +134,7 @@ public:
+ auto promise = mPendingPromises.value(key, nullptr);
+ if (!promise) {
+ promise = new AccountPromise(q);
+- QObject::connect(promise, &QObject::destroyed, q, [key, this]() {
++ QObject::connect(promise, &AccountPromise::finished, q, [key, this]() {
+ mPendingPromises.remove(key);
+ });
+ mPendingPromises.insert(key, promise);
+--
+GitLab
+
diff --git a/kde-apps/libkgapi/files/libkgapi-22.08.3-dont-cache-promises-for-AccountManager-findAccount.patch b/kde-apps/libkgapi/files/libkgapi-22.08.3-dont-cache-promises-for-AccountManager-findAccount.patch
new file mode 100644
index 000000000000..b24b80377686
--- /dev/null
+++ b/kde-apps/libkgapi/files/libkgapi-22.08.3-dont-cache-promises-for-AccountManager-findAccount.patch
@@ -0,0 +1,75 @@
+From d677a08c21fd99e7e8be0a0899f797f9237207e4 Mon Sep 17 00:00:00 2001
+From: Fabian Vogt <fabian@ritter-vogt.de>
+Date: Mon, 21 Nov 2022 13:02:27 +0100
+Subject: [PATCH] Don't cache promises for AccountManager::findAccount
+
+Unlike AccountManager::getAccount and AccountManager::refreshTokens, this
+method does not return an authenticated account. However, the promises are
+cached for all of them in the same store, so it was possible for a call to
+e.g. refreshTokens to get a promise created by findAccount instead, resulting
+in an unexpected result. Just don't cache promises created by findAccount.
+
+BUG: 406839
+BUG: 409122
+BUG: 421664
+BUG: 456923
+---
+ src/core/accountmanager.cpp | 38 ++++++++++++++++++-------------------
+ 1 file changed, 18 insertions(+), 20 deletions(-)
+
+diff --git a/src/core/accountmanager.cpp b/src/core/accountmanager.cpp
+index da5c37b6..c6b8189d 100644
+--- a/src/core/accountmanager.cpp
++++ b/src/core/accountmanager.cpp
+@@ -265,30 +265,28 @@ AccountPromise *AccountManager::refreshTokens(const QString &apiKey, const QStri
+
+ AccountPromise *AccountManager::findAccount(const QString &apiKey, const QString &accountName, const QList<QUrl> &scopes)
+ {
+- auto promise = d->createPromise(apiKey, accountName);
+- if (!promise->d->isRunning()) {
+- QTimer::singleShot(0, this, [=]() {
+- d->ensureStore([=](bool storeOpened) {
+- if (!storeOpened) {
+- promise->d->setError(tr("Failed to open account store"));
+- return;
+- }
++ auto promise = new AccountPromise(this);
++ QTimer::singleShot(0, this, [=]() {
++ d->ensureStore([=](bool storeOpened) {
++ if (!storeOpened) {
++ promise->d->setError(tr("Failed to open account store"));
++ return;
++ }
+
+- const auto account = d->mStore->getAccount(apiKey, accountName);
+- if (!account) {
+- promise->d->setAccount({});
++ const auto account = d->mStore->getAccount(apiKey, accountName);
++ if (!account) {
++ promise->d->setAccount({});
++ } else {
++ const auto currentScopes = account->scopes();
++ if (scopes.isEmpty() || d->compareScopes(currentScopes, scopes)) {
++ promise->d->setAccount(account);
+ } else {
+- const auto currentScopes = account->scopes();
+- if (scopes.isEmpty() || d->compareScopes(currentScopes, scopes)) {
+- promise->d->setAccount(account);
+- } else {
+- promise->d->setAccount({});
+- }
++ promise->d->setAccount({});
+ }
+- });
++ }
+ });
+- promise->d->setRunning();
+- }
++ });
++ promise->d->setRunning();
+ return promise;
+ }
+
+--
+GitLab
+
diff --git a/kde-apps/libkgapi/libkgapi-22.08.3-r1.ebuild b/kde-apps/libkgapi/libkgapi-22.08.3-r1.ebuild
new file mode 100644
index 000000000000..a46cb2350c58
--- /dev/null
+++ b/kde-apps/libkgapi/libkgapi-22.08.3-r1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_TEST="true"
+KFMIN=5.96.0
+QTMIN=5.15.5
+VIRTUALX_REQUIRED="test"
+inherit ecm gear.kde.org
+
+DESCRIPTION="Library for accessing Google calendar and contact resources"
+HOMEPAGE="https://api.kde.org/kdepim/libkgapi/html/index.html"
+
+LICENSE="LGPL-2.1+"
+SLOT="5"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
+IUSE="nls"
+
+DEPEND="
+ dev-libs/cyrus-sasl:2
+ >=dev-qt/qtgui-${QTMIN}:5
+ >=dev-qt/qtnetwork-${QTMIN}:5
+ >=dev-qt/qtwidgets-${QTMIN}:5
+ >=dev-qt/qtxml-${QTMIN}:5
+ >=kde-frameworks/kcalendarcore-${KFMIN}:5
+ >=kde-frameworks/kcontacts-${KFMIN}:5
+ >=kde-frameworks/kwallet-${KFMIN}:5
+"
+RDEPEND="${DEPEND}"
+BDEPEND="nls? ( >=dev-qt/linguist-tools-${QTMIN}:5 )"
+
+PATCHES=(
+ "${FILESDIR}/${P}-AccountManager-dont-keep-finished-promises-in-cache.patch"
+ "${FILESDIR}/${P}-dont-cache-promises-for-AccountManager-findAccount.patch"
+)
+
+src_test() {
+ local myctestargs=(
+ # Both fail for multiple distros, see bug #832709 for more discussion
+ # Revisit at least once Qt 5.15.3 is in wider distribution (in Gentoo at least):
+ # contacts-contactcreatejobtest, contacts-contactmodifyjobtest
+ # More failures not specific to Gentoo, bug #852593, KDE-bug #440648:
+ # calendar-eventcreatejobtest, calendar-eventfetchjobtest, calendar-eventmodifyjobtest
+ -E "(contacts-contactcreatejobtest|contacts-contactmodifyjobtest|calendar-eventcreatejobtest|calendar-eventfetchjobtest|calendar-eventmodifyjobtest)"
+ )
+
+ virtx cmake_src_test
+}