From 0c8a819f8a3c31360e3f6044374aa219e93ec21e Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 8 May 2021 10:07:54 +0200 Subject: Fix joinedRoom signal not being emitted in some cases An alternative implementation of #463 (and thanks to Carl for spotting the original problem). --- lib/connection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/connection.cpp b/lib/connection.cpp index 579c7920..a384783c 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -807,7 +807,7 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias, // that may add their own slots to finished(). connect(job, &BaseJob::finished, this, [this, job] { if (job->status().good()) - provideRoom(job->roomId()); + provideRoom(job->roomId(), JoinState::Join); }); return job; } @@ -1464,11 +1464,13 @@ Room* Connection::provideRoom(const QString& id, Omittable joinState) room = d->roomMap.value({ id, true }, nullptr); if (room) return room; - // No Invite either, setup a new room object below + // No Invite either, setup a new room object in Join state + joinState = JoinState::Join; } if (!room) { - room = roomFactory()(this, id, joinState.value_or(JoinState::Join)); + Q_ASSERT(joinState.has_value()); + room = roomFactory()(this, id, *joinState); if (!room) { qCCritical(MAIN) << "Failed to create a room" << id; return nullptr; -- cgit v1.2.3