From d6f39dcb0de69322479f287514a8c36afcb3fe7b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 14 May 2019 15:29:56 +0900 Subject: User::Private::makeHueF: Fix trying to use the moved value --- lib/user.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/user.cpp') diff --git a/lib/user.cpp b/lib/user.cpp index fdb82a38..7f3f11f6 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -50,21 +50,23 @@ class User::Private return Avatar(move(url)); } - qreal makeHueF(QString userId) + qreal makeHueF() { + Q_ASSERT(!userId.isEmpty()); QByteArray hash = QCryptographicHash::hash(userId.toUtf8(), QCryptographicHash::Sha1); QDataStream dataStream(qToLittleEndian(hash).left(2)); dataStream.setByteOrder(QDataStream::LittleEndian); quint16 hashValue; dataStream >> hashValue; - qreal hueF = static_cast(hashValue)/std::numeric_limits::max(); + const auto hueF = + qreal(hashValue)/std::numeric_limits::max(); Q_ASSERT((0 <= hueF) && (hueF <= 1)); return hueF; } Private(QString userId, Connection* connection) - : userId(move(userId)), connection(connection), hueF(makeHueF(userId)) + : userId(move(userId)), connection(connection), hueF(makeHueF()) { } QString userId; -- cgit v1.2.3