aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-10-17 09:59:37 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-10-17 09:59:37 +0900
commit0a82e68f86a3b4716ebada39c041a6c8673d2999 (patch)
treebc53b86920a30be29416b3f52539204b993de84a
parentcfb58baeacf97f2d54348f4e5efd6c203ddc002a (diff)
downloadlibquotient-0a82e68f86a3b4716ebada39c041a6c8673d2999.tar.gz
libquotient-0a82e68f86a3b4716ebada39c041a6c8673d2999.zip
Connection::joinRoom: make sure the room object is created early enough
All direct slots connected to finished() will run before success() is even emitted; so create the room object in the earliest slot connected to finished(), rather than to success().
-rw-r--r--lib/connection.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 2c5bf574..25f1c3f6 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -534,10 +534,14 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias,
const QStringList& serverNames)
{
auto job = callApi<JoinRoomJob>(roomAlias, serverNames);
- // Upon completion, ensure a room object in Join state is created but only
- // if it's not already there due to a sync completing earlier.
- connect(job, &JoinRoomJob::success, this,
- [this, job] { provideRoom(job->roomId()); });
+ // Upon completion, ensure a room object in Join state is created
+ // (or it might already be there due to a sync completing earlier).
+ // finished() is used here instead of success() to overtake clients
+ // that may add their own slots to finished().
+ connect(job, &BaseJob::finished, this, [this, job] {
+ if (job->status().good())
+ provideRoom(job->roomId());
+ });
return job;
}