Commit 2bfd14db authored by Tim Jenssen's avatar Tim Jenssen
Browse files

QmlPuppet: Fix compile with Qt older than 5.2



Change-Id: I0ef3c5e374b1b01c22b553b99dfbd8eb7783fa90
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 1a264461
......@@ -53,6 +53,14 @@
#define NAME_MAX PSHMNAMLEN
#endif
#ifndef QStringLiteral
#define QStringLiteral(str) QString::fromUtf8(str)
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
#include <QRegExp>
#endif
namespace QmlDesigner {
class SharedMemoryLocker
......@@ -94,8 +102,17 @@ static QByteArray makePlatformSafeKey(const QString &key)
{
if (key.isEmpty())
return QByteArray();
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
QByteArray data(QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64());
QString ambiguousChars(QStringLiteral("[=~<>|?*!@#$%^&:,; \\\\]"));
QByteArray normalizedData;
normalizedData = QString(data).replace(QRegExp(ambiguousChars), QStringLiteral("_")).toLatin1();
return normalizedData;
#else
return QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment