From 3a763fd470b8aeffa3d412e6f605231492fb5b0c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 27 Apr 2018 13:34:52 +0900 Subject: Fix broken User::displayName() logic Also, add an assert to Connection::user() to make sure it doesn't create users with invalid ids. Closes #201. --- lib/connection.cpp | 1 + lib/user.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/connection.cpp b/lib/connection.cpp index 241fa43d..f2bbf903 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -590,6 +590,7 @@ Room* Connection::invitation(const QString& roomId) const User* Connection::user(const QString& userId) { + Q_ASSERT(userId.startsWith('@') && userId.contains(':')); if( d->userMap.contains(userId) ) return d->userMap.value(userId); auto* user = userFactory(this, userId); diff --git a/lib/user.cpp b/lib/user.cpp index 88d20276..c4fbfe35 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -311,7 +311,7 @@ QString User::displayname(const Room* room) const { auto name = d->nameForRoom(room); return name.isEmpty() ? d->userId : - room ? room->roomMembername(name) : name; + room ? room->roomMembername(this) : name; } QString User::fullName(const Room* room) const -- cgit v1.2.3