forked from qt-creator/qt-creator
QmlPuppet: Fix compile with Qt older than 5.2
Change-Id: I0ef3c5e374b1b01c22b553b99dfbd8eb7783fa90 Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user