diff options
author | hjk <[email protected]> | 2023-06-06 09:00:27 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2023-06-06 07:45:27 +0000 |
commit | cfa88ac1692a49a560a8e6c5b05b5e57767002cf (patch) | |
tree | 7b9c08ec2d33c29e440562944a02121b066c05b5 | |
parent | 82966bc7baf480da14e6b5b03cc95a4a00cb0ec0 (diff) |
QmlJS: Avoid deprecation warning
de18b3ff370543b5b99bd068b871a2cd677cf9f3 deprecated the
QCryptographicHash::addData(const char *data, qsizetype length)
overload.
Change-Id: I86444a9d7de3cafc596f508fc08c3a4c1f25142f
Reviewed-by: Eike Ziller <[email protected]>
-rw-r--r-- | src/libs/qmljs/qmljsdocument.cpp | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index 16b17b0faee..4b79bdafccc 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -369,61 +369,62 @@ LibraryInfo::LibraryInfo(const QmlDirParser &parser, const QByteArray &fingerpri QByteArray LibraryInfo::calculateFingerprint() const { QCryptographicHash hash(QCryptographicHash::Sha1); - hash.addData(reinterpret_cast<const char *>(&_status), sizeof(_status)); + auto addData = [&hash](auto p, size_t len) { + hash.addData(QByteArrayView(reinterpret_cast<const char *>(p), len)); + }; + + addData(&_status, sizeof(_status)); int len = _components.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); for (const QmlDirParser::Component &component : _components) { len = component.fileName.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(component.fileName.constData()), - len * sizeofQChar); - hash.addData(reinterpret_cast<const char *>(&component.majorVersion), sizeof(component.majorVersion)); - hash.addData(reinterpret_cast<const char *>(&component.minorVersion), sizeof(component.minorVersion)); + addData(&len, sizeof(len)); + addData(component.fileName.constData(), len * sizeofQChar); + addData(&component.majorVersion, sizeof(component.majorVersion)); + addData(&component.minorVersion, sizeof(component.minorVersion)); len = component.typeName.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(component.typeName.constData()), - component.typeName.size() * sizeofQChar); + addData(&len, sizeof(len)); + addData(component.typeName.constData(), component.typeName.size() * sizeofQChar); int flags = (component.singleton ? (1 << 0) : 0) + (component.internal ? (1 << 1) : 0); - hash.addData(reinterpret_cast<const char *>(&flags), sizeof(flags)); + addData(&flags, sizeof(flags)); } len = _plugins.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); for (const QmlDirParser::Plugin &plugin : _plugins) { len = plugin.path.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(plugin.path.constData()), len * sizeofQChar); + addData(&len, sizeof(len)); + addData(plugin.path.constData(), len * sizeofQChar); len = plugin.name.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(plugin.name.constData()), len * sizeofQChar); + addData(&len, sizeof(len)); + addData(plugin.name.constData(), len * sizeofQChar); } len = _typeinfos.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); for (const QString &typeinfo : _typeinfos) { len = typeinfo.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(typeinfo.constData()), - len * sizeofQChar); + addData(&len, sizeof(len)); + addData(typeinfo.constData(), len * sizeofQChar); } len = _metaObjects.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); QList<QByteArray> metaFingerprints; for (const LanguageUtils::FakeMetaObject::ConstPtr &metaObject : _metaObjects) metaFingerprints.append(metaObject->fingerprint()); std::sort(metaFingerprints.begin(), metaFingerprints.end()); for (const QByteArray &fp : std::as_const(metaFingerprints)) hash.addData(fp); - hash.addData(reinterpret_cast<const char *>(&_dumpStatus), sizeof(_dumpStatus)); + addData(&_dumpStatus, sizeof(_dumpStatus)); len = _dumpError.size(); // localization dependent (avoid?) - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); - hash.addData(reinterpret_cast<const char *>(_dumpError.constData()), len * sizeofQChar); + addData(&len, sizeof(len)); + addData(_dumpError.constData(), len * sizeofQChar); len = _moduleApis.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); for (const ModuleApiInfo &moduleInfo : _moduleApis) moduleInfo.addToHash(hash); // make it order independent? len = _imports.size(); - hash.addData(reinterpret_cast<const char *>(&len), sizeof(len)); + addData(&len, sizeof(len)); for (const QmlDirParser::Import &import : _imports) hash.addData(import.module.toUtf8()); // import order matters, keep order-dependent |