diff options
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/roommessagesjob.cpp | 8 | ||||
-rw-r--r-- | jobs/roommessagesjob.h | 2 | ||||
-rw-r--r-- | jobs/syncjob.cpp | 3 | ||||
-rw-r--r-- | jobs/syncjob.h | 33 |
4 files changed, 7 insertions, 39 deletions
diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index 1e53f601..7a0bc756 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -28,7 +28,7 @@ class RoomMessagesJob::Private public: Private() {} - Events events; + Owning<Events> events; QString end; }; @@ -49,9 +49,9 @@ RoomMessagesJob::~RoomMessagesJob() delete d; } -Events RoomMessagesJob::events() +Events RoomMessagesJob::releaseEvents() { - return d->events; + return d->events.release(); } QString RoomMessagesJob::end() @@ -62,7 +62,7 @@ QString RoomMessagesJob::end() BaseJob::Status RoomMessagesJob::parseJson(const QJsonDocument& data) { QJsonObject obj = data.object(); - d->events = eventsFromJson(obj.value("chunk").toArray()); + d->events.assign(eventsFromJson(obj.value("chunk").toArray())); d->end = obj.value("end").toString(); return Success; } diff --git a/jobs/roommessagesjob.h b/jobs/roommessagesjob.h index 348217cc..fd6a131d 100644 --- a/jobs/roommessagesjob.h +++ b/jobs/roommessagesjob.h @@ -35,7 +35,7 @@ namespace QMatrixClient FetchDirectory dir = FetchDirectory::Backwards, int limit=10); virtual ~RoomMessagesJob(); - Events events(); + Events releaseEvents(); QString end(); protected: diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 554ac0f7..cec9595f 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -96,8 +96,7 @@ BaseJob::Status SyncJob::parseJson(const QJsonDocument& data) void SyncRoomData::EventList::fromJson(const QJsonObject& roomContents) { - auto l = eventsFromJson(roomContents[jsonKey].toObject()["events"].toArray()); - swap(l); + assign(eventsFromJson(roomContents[jsonKey].toObject()["events"].toArray())); } SyncRoomData::SyncRoomData(QString roomId_, JoinState joinState_, const QJsonObject& room_) diff --git a/jobs/syncjob.h b/jobs/syncjob.h index be1d4776..b41c09d4 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -22,41 +22,10 @@ #include "../joinstate.h" #include "../events/event.h" +#include "util.h" namespace QMatrixClient { - /** - * @brief A crude wrapper around a container of pointers that owns pointers - * to contained objects - * - * Similar to vector<unique_ptr<>>, upon deletion, EventsHolder - * will delete all events contained in it. - */ - template <typename ContainerT> - class Owning : public ContainerT - { - public: - Owning() = default; -#if defined(_MSC_VER) && _MSC_VER < 1900 - // Workaround: Dangerous (auto_ptr style) copy constructor because - // VS2013 (unnecessarily) instantiates EventList::QVector<>::toList() - // which instantiates QList< Owning<> > which needs the contained - // object to have a non-deleted copy constructor. - Owning(Owning& other) : ContainerT(std::move(other)) { } -#else - Owning(Owning&) = delete; -#endif - Owning(Owning&& other) : ContainerT(std::move(other)) { } - ~Owning() { for (auto e: *this) delete e; } - - /** - * @brief returns the underlying events and releases the ownership - * - * Acts similar to unique_ptr::release. - */ - ContainerT release() { return std::move(*this); } - }; - class SyncRoomData { public: |