diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-05-14 15:29:56 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-05-14 15:30:36 +0900 |
commit | d6f39dcb0de69322479f287514a8c36afcb3fe7b (patch) | |
tree | 4866a55ebe6d1874780c2d67f46a95f3c26ce622 | |
parent | fc8a8bb521daeb6ef2fd3353ba516c8393c27f7e (diff) | |
download | libquotient-d6f39dcb0de69322479f287514a8c36afcb3fe7b.tar.gz libquotient-d6f39dcb0de69322479f287514a8c36afcb3fe7b.zip |
User::Private::makeHueF: Fix trying to use the moved value
-rw-r--r-- | lib/user.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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<qreal>(hashValue)/std::numeric_limits<quint16>::max(); + const auto hueF = + qreal(hashValue)/std::numeric_limits<quint16>::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; |