diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-09-09 18:23:17 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-09-09 18:23:17 +0900 |
commit | 2a1596c16baad77fc80391c66694101f91028deb (patch) | |
tree | 3ac1ad73e1a6bc8a3e479eaa073593d4329121ff | |
parent | 3b8cf1a5b1277b1df0981ee41d24d6b3dcea51e6 (diff) | |
download | libquotient-2a1596c16baad77fc80391c66694101f91028deb.tar.gz libquotient-2a1596c16baad77fc80391c66694101f91028deb.zip |
Room::beforeDestruction()
This is to allow connecting to before-destruction of one specific room, rather than any room under a connection (for which Connection::aboutToDeleteRoom() still exists).
-rw-r--r-- | lib/connection.cpp | 6 | ||||
-rw-r--r-- | lib/room.h | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 4a24de09..cf3446ff 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -656,7 +656,7 @@ ForgetRoomJob* Connection::forgetRoom(const QString& id) qCDebug(MAIN) << "Room" << r->objectName() << "in state" << toCString(r->joinState()) << "will be deleted"; - emit aboutToDeleteRoom(r); + emit r->beforeDestruction(r); r->deleteLater(); } }); @@ -995,6 +995,8 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState) } d->roomMap.insert(roomKey, room); d->firstTimeRooms.push_back(room); + connect(room, &Room::beforeDestruction, + this, &Connection::aboutToDeleteRoom); emit newRoom(room); } if (joinState == JoinState::Invite) @@ -1015,7 +1017,7 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState) if (prevInvite) { qCDebug(MAIN) << "Deleting Invite state for room" << prevInvite->id(); - emit aboutToDeleteRoom(prevInvite); + emit prevInvite->beforeDestruction(prevInvite); prevInvite->deleteLater(); } } @@ -400,6 +400,9 @@ namespace QMatrixClient void fileTransferFailed(QString id, QString errorMessage = {}); void fileTransferCancelled(QString id); + /// The room is about to be deleted + void beforeDestruction(Room*); + public: // Used by Connection - not a part of the client API QJsonObject toJson() const; void updateData(SyncRoomData&& data ); |