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-apps/libkgapi/files/, kde-apps/libkgapi/
Date: Sat, 28 Jan 2023 22:48:44 +0000 (UTC)	[thread overview]
Message-ID: <1674945146.93ce4f04790e887e14d4176fe1f931e07f9c31aa.asturm@gentoo> (raw)

commit:     93ce4f04790e887e14d4176fe1f931e07f9c31aa
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 28 21:45:47 2023 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sat Jan 28 22:32:26 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=93ce4f04

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

 ...ager-dont-keep-finished-promises-in-cache.patch | 27 ++++++++
 ...e-promises-for-AccountManager-findAccount.patch | 75 ++++++++++++++++++++++
 kde-apps/libkgapi/libkgapi-22.08.3-r1.ebuild       | 49 ++++++++++++++
 3 files changed, 151 insertions(+)

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


             reply	other threads:[~2023-01-28 22:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28 22:48 Andreas Sturmlechner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-15  7:13 [gentoo-commits] repo/gentoo:master commit in: kde-apps/libkgapi/files/, kde-apps/libkgapi/ Sam James
2021-02-24 22:40 Andreas Sturmlechner
2021-01-14 19:49 Andreas Sturmlechner
2020-11-25 13:17 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=1674945146.93ce4f04790e887e14d4176fe1f931e07f9c31aa.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