diff options
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index c72cf31..c14a62e 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "applicationdomaintype.h" | 22 | #include "applicationdomaintype.h" |
23 | #include <QDateTime> | 23 | #include <QDateTime> |
24 | #include <QDataStream> | ||
24 | #include "mail_generated.h" | 25 | #include "mail_generated.h" |
25 | #include "contact_generated.h" | 26 | #include "contact_generated.h" |
26 | 27 | ||
@@ -66,7 +67,10 @@ template <> | |||
66 | flatbuffers::uoffset_t variantToProperty<QDateTime>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 67 | flatbuffers::uoffset_t variantToProperty<QDateTime>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
67 | { | 68 | { |
68 | if (property.isValid()) { | 69 | if (property.isValid()) { |
69 | return fbb.CreateString(property.toDateTime().toString().toStdString()).o; | 70 | QByteArray ba; |
71 | QDataStream ds(&ba, QIODevice::WriteOnly); | ||
72 | ds << property.toDateTime(); | ||
73 | return fbb.CreateString(ba.toStdString()).o; | ||
70 | } | 74 | } |
71 | return 0; | 75 | return 0; |
72 | } | 76 | } |
@@ -256,8 +260,11 @@ template <> | |||
256 | QVariant propertyToVariant<QDateTime>(const flatbuffers::String *property) | 260 | QVariant propertyToVariant<QDateTime>(const flatbuffers::String *property) |
257 | { | 261 | { |
258 | if (property) { | 262 | if (property) { |
259 | // We have to copy the memory, otherwise it would become eventually invalid | 263 | auto ba = QByteArray::fromRawData(property->c_str(), property->size()); |
260 | return QDateTime::fromString(QString::fromStdString(property->c_str())); | 264 | QDateTime dt; |
265 | QDataStream ds(&ba, QIODevice::ReadOnly); | ||
266 | ds >> dt; | ||
267 | return dt; | ||
261 | } | 268 | } |
262 | return QVariant(); | 269 | return QVariant(); |
263 | } | 270 | } |