diff --git a/include/QtCrypto/qca_support.h b/include/QtCrypto/qca_support.h index 38d48b39..fd5dda4a 100644 --- a/include/QtCrypto/qca_support.h +++ b/include/QtCrypto/qca_support.h @@ -98,9 +98,13 @@ myTypeName = QCA::methodReturnType( testClass.metaObject(), QByteArray( "boolMet \relates SyncThread */ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QCA_EXPORT int methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList &argTypes); +#else QCA_EXPORT QByteArray methodReturnType(const QMetaObject * obj, const QByteArray & method, const QList argTypes); +#endif /** Convenience method to invoke a method by name, using a variant diff --git a/plugins/qca-gnupg/gpgproc/sprocess.cpp b/plugins/qca-gnupg/gpgproc/sprocess.cpp index 6686f027..4eba7ac7 100644 --- a/plugins/qca-gnupg/gpgproc/sprocess.cpp +++ b/plugins/qca-gnupg/gpgproc/sprocess.cpp @@ -32,6 +32,13 @@ namespace gpgQCAPlugin { SProcess::SProcess(QObject *parent) : QProcess(parent) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + setChildProcessModifier([this]() { + // set the pipes to be inheritable + for (int n = 0; n < pipeList.count(); ++n) + ::fcntl(pipeList[n], F_SETFD, (::fcntl(pipeList[n], F_GETFD) & ~FD_CLOEXEC)); + }); +#endif } SProcess::~SProcess() @@ -44,6 +51,7 @@ void SProcess::setInheritPipeList(const QList &list) pipeList = list; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void SProcess::setupChildProcess() { // set the pipes to be inheritable @@ -51,5 +59,6 @@ void SProcess::setupChildProcess() ::fcntl(pipeList[n], F_SETFD, (::fcntl(pipeList[n], F_GETFD) & ~FD_CLOEXEC)); } #endif +#endif } diff --git a/plugins/qca-gnupg/gpgproc/sprocess.h b/plugins/qca-gnupg/gpgproc/sprocess.h index 677f6169..44c9d0fc 100644 --- a/plugins/qca-gnupg/gpgproc/sprocess.h +++ b/plugins/qca-gnupg/gpgproc/sprocess.h @@ -34,8 +34,10 @@ public: #ifdef Q_OS_UNIX void setInheritPipeList(const QList &); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) protected: void setupChildProcess() override; +#endif private: QList pipeList; diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp index 96549250..0d9f5d48 100644 --- a/plugins/qca-ossl/qca-ossl.cpp +++ b/plugins/qca-ossl/qca-ossl.cpp @@ -334,8 +334,12 @@ static CertificateInfo get_cert_name(X509_NAME *name) { CertificateInfo p9_info; try_get_name_item(name, NID_pkcs9_emailAddress, EmailLegacy, &p9_info); - const QList emails = info.values(Email); + const QList emails = info.values(Email); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QMultiMapIterator it(p9_info); +#else QMapIterator it(p9_info); +#endif while (it.hasNext()) { it.next(); if (!emails.contains(it.value())) @@ -1613,7 +1617,7 @@ static const auto DsaDeleter = [](DSA *pointer) { static bool make_dlgroup(const QByteArray &seed, int bits, int counter, DLParams *params) { - int ret_counter; + int ret_counter; std::unique_ptr dsa(DSA_new(), DsaDeleter); if (!dsa) return false; diff --git a/src/qca_cert.cpp b/src/qca_cert.cpp index 4fc027c7..610cd1f1 100644 --- a/src/qca_cert.cpp +++ b/src/qca_cert.cpp @@ -25,6 +25,8 @@ #include "qcaprovider.h" #include +#include +#include #include #include @@ -1343,7 +1345,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain) name = name.toLower(); // ensure the cert field contains valid characters only - if (QRegExp(QLatin1String("[^a-z0-9\\.\\*\\-]")).indexIn(name) >= 0) + if (QRegularExpression(QStringLiteral("[^a-z0-9\\.\\*\\-]")).match(name).hasMatch()) return false; // hack into parts, and require at least 1 part diff --git a/src/qca_core.cpp b/src/qca_core.cpp index d58a3c56..19cbff9a 100644 --- a/src/qca_core.cpp +++ b/src/qca_core.cpp @@ -541,7 +541,12 @@ static bool configIsValid(const QVariantMap &config) while (it.hasNext()) { it.next(); const QVariant &v = it.value(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (v.typeId() != QMetaType::QString && v.typeId() != QMetaType::Int && v.typeId() != QMetaType::Bool) +#else if (v.type() != QVariant::String && v.type() != QVariant::Int && v.type() != QVariant::Bool) + +#endif return false; } return true; diff --git a/src/support/console.cpp b/src/support/console.cpp index ce079002..43ccf6f0 100644 --- a/src/support/console.cpp +++ b/src/support/console.cpp @@ -848,7 +848,7 @@ public: result.resize(at * sizeof(ushort)); } return true; - } else if (c < 0x20) + } else if (c.unicode() < 0x20) return true; if (at >= CONSOLEPROMPT_INPUT_MAX) diff --git a/src/support/synchronizer.cpp b/src/support/synchronizer.cpp index 0eb5bc09..a1ab7ee1 100644 --- a/src/support/synchronizer.cpp +++ b/src/support/synchronizer.cpp @@ -342,7 +342,7 @@ public: , loop(nullptr) , agent(nullptr) , fixer(nullptr) - , m(QMutex::NonRecursive) + , m() , w() , orig_thread(nullptr) { diff --git a/src/support/syncthread.cpp b/src/support/syncthread.cpp index 9810e6d7..f15782ef 100644 --- a/src/support/syncthread.cpp +++ b/src/support/syncthread.cpp @@ -27,11 +27,15 @@ namespace QCA { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +int methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList &argTypes) +#else QByteArray methodReturnType( const QMetaObject * obj, const QByteArray & method, const QList argTypes) // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param) // TODO make argTypes const & when we break ABI +#endif { for (int n = 0; n < obj->methodCount(); ++n) { QMetaMethod m = obj->method(n); @@ -45,9 +49,17 @@ QByteArray methodReturnType( if (m.parameterTypes() != argTypes) continue; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return m.returnType(); +#else return m.typeName(); +#endif } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType::UnknownType; +#else return QByteArray(); +#endif } bool invokeMethodWithVariants(QObject * obj, @@ -61,10 +73,17 @@ bool invokeMethodWithVariants(QObject * obj, return false; QList argTypes; - for (int n = 0; n < args.count(); ++n) + for (int n = 0; n < args.count(); ++n) { argTypes += args[n].typeName(); + } // get return type +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const auto metatype = methodReturnType(obj->metaObject(), method, argTypes); + if (metatype == QMetaType::UnknownType) { + return false; + } +#else int metatype = QMetaType::Void; const QByteArray retTypeName = methodReturnType(obj->metaObject(), method, argTypes); if (!retTypeName.isEmpty() && retTypeName != "void") { @@ -72,6 +91,7 @@ bool invokeMethodWithVariants(QObject * obj, if (metatype == QMetaType::UnknownType) // lookup failed return false; } +#endif QGenericArgument arg[10]; for (int n = 0; n < args.count(); ++n) @@ -81,7 +101,11 @@ bool invokeMethodWithVariants(QObject * obj, QVariant retval; if (metatype != QMetaType::Void) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + retval = QVariant(QMetaType {metatype}, (const void *)nullptr); +#else retval = QVariant(metatype, (const void *)nullptr); +#endif retarg = QGenericReturnArgument(retval.typeName(), retval.data()); } diff --git a/tools/mozcerts/main.cpp b/tools/mozcerts/main.cpp index aaf9200a..1fbf0f32 100644 --- a/tools/mozcerts/main.cpp +++ b/tools/mozcerts/main.cpp @@ -23,6 +23,7 @@ #include #include +#include #include QStringList splitWithQuotes(const QString &in, char c); diff --git a/unittest/metatype/metatype.cpp b/unittest/metatype/metatype.cpp index 49bac65a..861ebf0e 100644 --- a/unittest/metatype/metatype.cpp +++ b/unittest/metatype/metatype.cpp @@ -105,6 +105,43 @@ void MetaTypeUnitTest::returnTypeTest() TestClass1 testClass1; QList args; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // returns a null type name because that is what void does... + QCOMPARE(QMetaType::Void, QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args)); + QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args)); + + // returns a null type, because args don't match + QCOMPARE(QMetaType::UnknownType, QCA::methodReturnType(testClass1.metaObject(), QByteArray("boolMethod"), args)); + + args << "QString"; + QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("returnArg"), args)); + QCOMPARE(QMetaType::Bool, QCA::methodReturnType(testClass1.metaObject(), QByteArray("boolMethod"), args)); + args.clear(); + + args << "QByteArray"; + QCOMPARE(QMetaType::QByteArray, QCA::methodReturnType(testClass1.metaObject(), QByteArray("returnArg"), args)); + args.clear(); + + args << "QString" + << "int" + << "int" + << "int" + << "int" + << "int" + << "int" + << "int" + << "int"; + + // wrong number of arguments - has 9, needs 10 + QCOMPARE(QMetaType::UnknownType, QCA::methodReturnType(testClass1.metaObject(), QByteArray("tenArgs"), args)); + + // match + args << "int"; + QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("tenArgs"), args)); + + args << "int"; + QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args)); +#else // returns a null type name because that is what void does... QCOMPARE(QByteArray("void"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args)); QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args)); @@ -140,6 +177,7 @@ void MetaTypeUnitTest::returnTypeTest() args << "int"; QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args)); +#endif } void MetaTypeUnitTest::invokeMethodTest()