summaryrefslogtreecommitdiffstats
path: root/src/calendarstore.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-24 16:31:25 +0200
committerDanilo M. <danix@danix.xyz>2026-09-24 16:31:25 +0200
commit27f9e90b26622beb47d4f00e7f21a56b365ccfaf (patch)
tree543af8caa246fc16449a4cf47e6ba43990e3f960 /src/calendarstore.cpp
parent2c3741619a3e0f11911af7100e3f763ded9077cf (diff)
downloadqtmaildir-27f9e90b26622beb47d4f00e7f21a56b365ccfaf.tar.gz
qtmaildir-27f9e90b26622beb47d4f00e7f21a56b365ccfaf.zip
fix: compare sameMeaning overrides by recurrence id and check the uid
Diffstat (limited to 'src/calendarstore.cpp')
-rw-r--r--src/calendarstore.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/calendarstore.cpp b/src/calendarstore.cpp
index 92a7b74..c388cd6 100644
--- a/src/calendarstore.cpp
+++ b/src/calendarstore.cpp
@@ -604,10 +604,20 @@ bool sameMeaning(const QByteArray &a, const QByteArray &b)
const CalEvent y = parseEvent(b, {}, {}, &ignored);
if (x.uid.isEmpty() || y.uid.isEmpty())
return x.uid.isEmpty() && y.uid.isEmpty();
+ if (x.uid != y.uid)
+ return false;
if (x.overrides.size() != y.overrides.size())
return false;
- for (int i = 0; i < x.overrides.size(); ++i) {
- const CalOverride &p = x.overrides[i], &q = y.overrides[i];
+ // Overrides are separate VEVENTs whose file order is not semantic, and a
+ // server may normalise it, so pair them by recurrence id, not by index.
+ QList<CalOverride> xo = x.overrides, yo = y.overrides;
+ const auto byRecurrenceId = [](const CalOverride &a, const CalOverride &b) {
+ return a.recurrenceId < b.recurrenceId;
+ };
+ std::stable_sort(xo.begin(), xo.end(), byRecurrenceId);
+ std::stable_sort(yo.begin(), yo.end(), byRecurrenceId);
+ for (int i = 0; i < xo.size(); ++i) {
+ const CalOverride &p = xo[i], &q = yo[i];
if (p.recurrenceId != q.recurrenceId || p.start != q.start
|| p.end != q.end || p.summary != q.summary || p.cancelled != q.cancelled)
return false;