[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-addons/Applications/17.08] plugins/plasma/pimeventsplugin: PimEventsPlugin: handle Items wit
From:       Daniel_Vrátil <null () kde ! org>
Date:       2017-08-25 12:54:10
Message-ID: E1dlE7m-00017C-2j () code ! kde ! org
[Download RAW message or body]

Git commit babdec9089cec4c43e0573f10cde84fffa742b83 by Daniel Vrátil.
Committed on 25/08/2017 at 12:54.
Pushed by dvratil into branch 'Applications/17.08'.

PimEventsPlugin: handle Items with no payload

Disregard Items without payload. Theoretically there should be no such Items,
but corrupted Kolab events sometimes end up in Akonadi as Items with no
or empty payload.

M  +10   -7    plugins/plasma/pimeventsplugin/eventmodel.cpp

https://commits.kde.org/kdepim-addons/babdec9089cec4c43e0573f10cde84fffa742b83

diff --git a/plugins/plasma/pimeventsplugin/eventmodel.cpp \
b/plugins/plasma/pimeventsplugin/eventmodel.cpp index aaf6a55f..eb888083 100644
--- a/plugins/plasma/pimeventsplugin/eventmodel.cpp
+++ b/plugins/plasma/pimeventsplugin/eventmodel.cpp
@@ -62,12 +62,12 @@ void EventModel::createMonitor()
     });
     connect(mMonitor, &Akonadi::Monitor::itemChanged,
             this, [this](const Akonadi::Item &item) {
-        KCalCore::Incidence::Ptr incidence;
-        try {
-            incidence = item.payload<KCalCore::Incidence::Ptr>();
-        } catch (const Akonadi::PayloadException &e) {
-            qCWarning(PIMEVENTSPLUGIN_LOG) << "Item" << item.id() << "has no \
payload:" << e.what(); +        if (!item.hasPayload<KCalCore::Incidence::Ptr>()) {
+            qCDebug(PIMEVENTSPLUGIN_LOG) << "Item" << item.id() << "has no \
payload!"; +            return;
         }
+
+        auto incidence = item.payload<KCalCore::Incidence::Ptr>();
         if (!incidence) {
             return;         // HUH?!
         }
@@ -154,8 +154,11 @@ void EventModel::onItemsReceived(const Akonadi::Item::List \
&items)  {
     qCDebug(PIMEVENTSPLUGIN_LOG) << "Batch: received" << items.count() << "items";
     for (const auto &item : items) {
-        incidenceChanger()->createFinished(0, item,
-                                           \
Akonadi::IncidenceChanger::ResultCodeSuccess, QString()); +        if \
(item.hasPayload<KCalCore::Incidence::Ptr>()) { +            \
incidenceChanger()->createFinished(0, item, \
Akonadi::IncidenceChanger::ResultCodeSuccess, QString()); +        } else {
+            qCDebug(PIMEVENTSPLUGIN_LOG) << "Item" << item.id() << "has no payload";
+        }
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic