2 commits - kolabformat/errorhandler.h kolabformat/kolabobject.cpp mime/mimeutils.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Thu Aug 9 18:18:01 CEST 2012
kolabformat/errorhandler.h | 8 ++++++++
kolabformat/kolabobject.cpp | 10 +++++++++-
mime/mimeutils.cpp | 2 +-
3 files changed, 18 insertions(+), 2 deletions(-)
New commits:
commit e454208a4bdf22504e8a833212691b3c3c4a2165
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Thu Aug 9 18:17:45 2012 +0200
not finding an attachment results in dataloss -> Error, debug messages
diff --git a/kolabformat/errorhandler.h b/kolabformat/errorhandler.h
index df40f93..2ce1694 100644
--- a/kolabformat/errorhandler.h
+++ b/kolabformat/errorhandler.h
@@ -79,6 +79,14 @@ public:
ErrorHandler::instance().clear();
}
+ static bool errorOccured()
+ {
+ if (ErrorHandler::instance().error() >= Error) {
+ return true;
+ }
+ return false;
+ }
+
private:
ErrorHandler():m_worstError(Debug) {};
ErrorHandler(const ErrorHandler &);
diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 3af8fc9..7e67c85 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -210,6 +210,9 @@ ObjectType KolabObjectReader::Private::readKolabV2(const KMime::Message::Ptr &ms
}
}
mObjectType = objectType;
+ if (ErrorHandler::errorOccured()) {
+ printMessageDebugInfo(msg);
+ }
return objectType;
}
@@ -277,6 +280,9 @@ ObjectType KolabObjectReader::Private::readKolabV3(const KMime::Message::Ptr &ms
// kDebug() << "getting attachments";
Mime::getAttachmentsById(mIncidence, msg);
}
+ if (ErrorHandler::errorOccured()) {
+ printMessageDebugInfo(msg);
+ }
ErrorHandler::handleLibkolabxmlErrors();
mObjectType = objectType;
return objectType;
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index b1020cf..60baaf6 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -272,7 +272,7 @@ void getAttachmentsById(KCalCore::Incidence::Ptr incidence, const KMime::Message
QString name;
KMime::Content *content = findContentById(mimeData, fromCid(attachment->uri()).toLatin1(), type, name);
if (!content) { // guard against malformed events with non-existent attachments
- Warning() << "could not find attachment: "<< name << type;
+ Error() << "could not find attachment: "<< name << type;
continue;
}
attachment->setUri(QString());
commit a6043daeaa7429294ec186a0cba409eda2297aab
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Thu Aug 9 18:16:27 2012 +0200
Don't crash if an attachment couldn't be found
diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 0b25ac5..3af8fc9 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -205,7 +205,9 @@ ObjectType KolabObjectReader::Private::readKolabV2(const KMime::Message::Ptr &ms
// kDebug() << "v2 attachments " << attachments.size() << d->mIncidence->attachments().size();
mIncidence->clearAttachments();
Mime::getAttachments(mIncidence, attachments, msg);
- Q_ASSERT(mIncidence->attachments().size() == attachments.size());
+ if (mIncidence->attachments().size() != attachments.size()) {
+ Error() << "Could not extract all attachments. " << mIncidence->attachments().size() << " out of " << attachments.size();
+ }
}
mObjectType = objectType;
return objectType;
More information about the commits
mailing list