6d0701455d
OBS-URL: https://build.opensuse.org/package/show/KDE:Applications/akonadi-server?expand=0&rev=7a2d7dcf9b3f2c4621daa10b158cdb28
57 lines
2.4 KiB
Diff
57 lines
2.4 KiB
Diff
From 1d8851495bcfa6ff5d3fa35882b68fdf68b21a7f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= <dvratil@kde.org>
|
|
Date: Thu, 21 Mar 2019 13:22:58 +0100
|
|
Subject: Fix a regression when updating attributes
|
|
|
|
This fixes a regression introduced in 3a062e6a and 6054e42d where some
|
|
attributes were not sent to the Akonadi server in update job even though
|
|
they were modified. This was due to a bad API design which returns a
|
|
non-const pointer to an attribute from a const method, so callers sometimes
|
|
modify the returned attribute on a const object. Since the method itself
|
|
is const though, it did not mark the attribute as modified.
|
|
|
|
Proper fix is to introduce a purely const and non-const overloads for
|
|
the attribute accessors, unfortunatelly this requires fixing a lot of our code
|
|
in many places first to not abuse the non-constness of the returned
|
|
attribute.
|
|
|
|
Note that since the code is in an inlined method, all clients should be
|
|
recompiled.
|
|
|
|
CCMAIL: faure@kde.org
|
|
---
|
|
src/core/collection.h | 13 +++++++++----
|
|
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/core/collection.h b/src/core/collection.h
|
|
index 50c0926..b5a496c 100644
|
|
--- a/src/core/collection.h
|
|
+++ b/src/core/collection.h
|
|
@@ -584,14 +584,19 @@ inline T *Akonadi::Collection::attribute(Collection::CreateOption option)
|
|
template <typename T>
|
|
inline T *Akonadi::Collection::attribute() const
|
|
{
|
|
- const T dummy;
|
|
- if (hasAttribute(dummy.type())) {
|
|
- T *attr = dynamic_cast<T *>(attribute(dummy.type()));
|
|
+ const QByteArray type = T().type();
|
|
+ if (hasAttribute(type)) {
|
|
+ T *attr = dynamic_cast<T *>(attribute(type));
|
|
if (attr) {
|
|
+ // FIXME: This method returns a non-const pointer, so callers may still modify the
|
|
+ // attribute. Unfortunately, just making this function return a const pointer and
|
|
+ // creating a non-const overload does not work, as many users of this function abuse the
|
|
+ // non-const pointer and modify the attribute even on a const object.
|
|
+ const_cast<Collection*>(this)->markAttributesChanged();
|
|
return attr;
|
|
}
|
|
//reuse 5250
|
|
- qWarning() << "Found attribute of unknown type" << dummy.type()
|
|
+ qWarning() << "Found attribute of unknown type" << type
|
|
<< ". Did you forget to call AttributeFactory::registerAttribute()?";
|
|
}
|
|
|
|
--
|
|
cgit v1.1
|
|
|