diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-14 18:41:55 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-14 18:41:55 +0900 |
commit | c5f480355c7d4c000a4ee73fd7f8107a9a9340c2 (patch) | |
tree | d7a8f51e75230aa48cd243ef40b17ced70c0216b /jobs/syncjob.h | |
parent | bb14969dfa5e9e8a26a005a7f804f21a62460f68 (diff) | |
download | libquotient-c5f480355c7d4c000a4ee73fd7f8107a9a9340c2.tar.gz libquotient-c5f480355c7d4c000a4ee73fd7f8107a9a9340c2.zip |
Move all internal event pointers to std::unique_ptr<>
This causes the following changes along the way:
- Owning<> template is decommissioned.
- event.h has been rearranged, and Event/RoomEvent::fromJson static methods have been replaced with an external makeEvent<> function template. A side effect of that is that one cannot use a factory with a type other than the one it's defined for (i.e. you cannot call makeEvent<TypingEvent>) but that feature has been out of use for long anyway.
- Room::doAddNewMessageEvents() and Room::doAddHistoricalMessageEvents() have been removed, giving place to Room::onAddNewTimelineEvents() and Room::onAddHistoricalTimelineEvents(). The most important difference is that all code that must be executed now resides in addNewMessageEvents() (it moved from Room to Room::Private) and classes inheriting from Room are not obliged to call the overridden function from the overriding function (they can do it but those functions have empty bodies in Room). This was a long overdue change, and owning pointers simply mandated it. Room::onAddNewTimelineEvents/onAddHistoricalTimelineEvents should not do anything with the passed range in terms of ownership, it's just a way to allow the derived class to update his data in due course.
- Room::Private::dropDuplicateEvents() and Room::Private::insertEvents(), notably, have been updated to work with owning pointers. insertEvents() move()s pointers to the timeline, while dropDuplicateEvents uses remove_if instead of stable_partition and doesn't explicitly delete event objects.
Also, a bugfix: Event accidentally had not virtual destructor for quite a long time. According to the standard, deleting an object through a pointer to a base class without a virtual destructor leads to UB. So the fact that libqmatrixclient clients even worked all these months is mere coincidence and compiler authors good will :-D
Diffstat (limited to 'jobs/syncjob.h')
-rw-r--r-- | jobs/syncjob.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/jobs/syncjob.h b/jobs/syncjob.h index 08bd773e..e9288486 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -30,7 +30,7 @@ namespace QMatrixClient { public: template <typename EventT> - class Batch : public Owning<EventsBatch<EventT>> + class Batch : public EventsBatch<EventT> { public: explicit Batch(QString k) : jsonKey(std::move(k)) { } |