From bace97aa5ba382191ccc616b33bbb11fe2b72f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 11 Feb 2020 16:31:10 +0100 Subject: Improve error message when mixing incompatible Qt library versions The implementation of the check has been moved to a single helper function. The reason for doing this check in QWidgetPrivate as well, when it's already done in QObjectPrivate, is to catch incompatible libraries where QtWidgets is the odd one out, e.g.: QtSomeModule 5.15.0 -> QtWidget 5.15.1 -> QtCore 5.15.0 Technically any non-final subclass of QObjectPrivate should have this check. Change-Id: Ia74064ad27de7335040a6d6b37d11574f818c878 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 10 +--------- src/corelib/kernel/qobject_p.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a51b794604..a8e2c43934 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -184,15 +184,7 @@ QMetaObject *QObjectData::dynamicMetaObject() const QObjectPrivate::QObjectPrivate(int version) : threadData(nullptr), currentChildBeingDeleted(nullptr) { -#ifdef QT_BUILD_INTERNAL - // Don't check the version parameter in internal builds. - // This allows incompatible versions to be loaded, possibly for testing. - Q_UNUSED(version); -#else - if (Q_UNLIKELY(version != QObjectPrivateVersion)) - qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", - version, QObjectPrivateVersion); -#endif + checkForIncompatibleLibraryVersion(version); // QObjectData initialization q_ptr = nullptr; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 838a9aa8c5..34b7447d5d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -322,6 +322,8 @@ public: virtual ~QObjectPrivate(); void deleteChildren(); + inline void checkForIncompatibleLibraryVersion(int version) const; + void setParent_helper(QObject *); void moveToThread_helper(); void setThreadData_helper(QThreadData *currentData, QThreadData *targetData); @@ -396,6 +398,28 @@ public: Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_MOVABLE_TYPE); +/* + Catch mixing of incompatible library versions. + + Should be called from the constructor of every non-final subclass + of QObjectPrivate, to ensure we catch incompatibilities between + the intermediate base and subclasses thereof. +*/ +inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) const +{ +#if defined(QT_BUILD_INTERNAL) + // Don't check the version parameter in internal builds. + // This allows incompatible versions to be loaded, possibly for testing. + Q_UNUSED(version); +#else + if (Q_UNLIKELY(version != QObjectPrivateVersion)) { + qFatal("Cannot mix incompatible Qt library (%d.%d.%d) with this library (%d.%d.%d)", + (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff, + (QObjectPrivateVersion >> 16) & 0xff, (QObjectPrivateVersion >> 8) & 0xff, QObjectPrivateVersion & 0xff); + } +#endif +} + inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const { return declarativeData && QAbstractDeclarativeData::isSignalConnected -- cgit v1.2.3 From 352c8ef1997542de2d471a8d929442529b876263 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 14:09:25 +0200 Subject: QMetaObject::connectSlotsByName(): Add output of connections Help porting connections over by printing the connection statements. [ChangeLog][QtCore][QObject] A logging category qt.core.qmetaobject.connectslotsbyname was added, which will produce about the connections made by QMetaObject::connectSlotsByName(). Task-number: QTBUG-76375 Change-Id: I9a57cae574156fc8ae5a4fb8e960c2f9a47a5e47 Reviewed-by: Volker Hilsheimer --- src/corelib/kernel/qobject.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a8e2c43934..8be10ed601 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -47,6 +47,7 @@ #include "qabstracteventdispatcher_p.h" #include "qcoreapplication.h" #include "qcoreapplication_p.h" +#include "qloggingcategory.h" #include "qvariant.h" #include "qmetaobject.h" #include @@ -78,6 +79,8 @@ QT_BEGIN_NAMESPACE static int DIRECT_CONNECTION_ONLY = 0; +Q_LOGGING_CATEGORY(lcConnections, "qt.core.qmetaobject.connectslotsbyname") + Q_CORE_EXPORT QBasicAtomicPointer qt_signal_spy_callback_set = Q_BASIC_ATOMIC_INITIALIZER(nullptr); void qt_register_signal_spy_callbacks(QSignalSpyCallbackSet *callback_set) @@ -3559,6 +3562,37 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, return success; } +// Helpers for formatting the connect statements of connectSlotsByName()'s debug mode +static QByteArray formatConnectionSignature(const char *className, const QMetaMethod &method) +{ + const auto signature = method.methodSignature(); + Q_ASSERT(signature.endsWith(')')); + const int openParen = signature.indexOf('('); + const bool hasParameters = openParen >= 0 && openParen < signature.size() - 2; + QByteArray result; + if (hasParameters) { + result += "qOverload<" + + signature.mid(openParen + 1, signature.size() - openParen - 2) + ">("; + } + result += '&'; + result += className + QByteArrayLiteral("::") + method.name(); + if (hasParameters) + result += ')'; + return result; +} + +static QByteArray msgConnect(const QMetaObject *senderMo, const QByteArray &senderName, + const QMetaMethod &signal, const QObject *receiver, int receiverIndex) +{ + const auto receiverMo = receiver->metaObject(); + const auto slot = receiverMo->method(receiverIndex); + QByteArray message = QByteArrayLiteral("QObject::connect(") + + senderName + ", " + formatConnectionSignature(senderMo->className(), signal) + + ", " + receiver->objectName().toLatin1() + ", " + + formatConnectionSignature(receiverMo->className(), slot) + ");"; + return message; +} + /*! \fn void QMetaObject::connectSlotsByName(QObject *object) @@ -3640,6 +3674,8 @@ void QMetaObject::connectSlotsByName(QObject *o) // we connect it... if (Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))) { foundIt = true; + qCDebug(lcConnections, "%s", + msgConnect(smeta, coName, QMetaObjectPrivate::signal(smeta, sigIndex), o, i).constData()); // ...and stop looking for further objects with the same name. // Note: the Designer will make sure each object name is unique in the above // 'list' but other code may create two child objects with the same name. In -- cgit v1.2.3 From d7b6c4288f2de8b0123c888e83a3fbcd84ed906f Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 9 Oct 2018 10:14:43 +1000 Subject: wasm: add platform qsettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the backend is async, the settings will not be ready to read/write instantly as on other platforms, but only be ready after the filesystem has been synced to the sandbox. This takes at least 250 to 500 ms. The QSettings status() or isWritable() can be used to discern when the settings are ready for use. This also fixes a crash in threaded wasm Task-number: QTBUG-70002 Change-Id: I080bdb940aa8e9a126d7358b524f32477db151b6 Reviewed-by: Morten Johan Sørvig --- src/corelib/kernel/qcoreapplication.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e25049f821..70f0a5ad4c 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -121,7 +121,6 @@ #endif #ifdef Q_OS_WASM -#include #include #endif @@ -497,13 +496,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint QCoreApplicationPrivate::~QCoreApplicationPrivate() { -#ifdef Q_OS_WASM - EM_ASM( - // unmount persistent directory as IDBFS - // see also QTBUG-70002 - FS.unmount('/home/web_user'); - ); -#endif #ifndef QT_NO_QOBJECT cleanupThreadData(); #endif @@ -795,17 +787,8 @@ void QCoreApplicationPrivate::init() Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = q; -#ifdef Q_OS_WASM - EM_ASM( - // mount and sync persistent filesystem to sandbox - FS.mount(IDBFS, {}, '/home/web_user'); - FS.syncfs(true, function(err) { - if (err) - Module.print(err); - }); - ); - #if QT_CONFIG(thread) +#ifdef Q_OS_WASM QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as(); #endif #endif -- cgit v1.2.3 From fb6acf08bbd7a68d027282251747620b942bd1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 18 Feb 2020 10:13:22 +0100 Subject: Replace usage of std::result_of with decltype It's slated for removal in c++20 Fixes: QTBUG-82240 Change-Id: I7b35c151413b131ca49b2c09b6382efc3fc8ccb6 Reviewed-by: Timur Pocheptsov --- src/corelib/kernel/qobjectdefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index dc2d832fe5..becbb90a61 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -532,7 +532,7 @@ struct Q_CORE_EXPORT QMetaObject static typename std::enable_if::IsPointerToMemberFunction && QtPrivate::FunctionPointer::ArgumentCount == -1 && !std::is_convertible::value, bool>::type - invokeMethod(QObject *context, Func function, typename std::result_of::type *ret) + invokeMethod(QObject *context, Func function, decltype(function()) *ret) { return invokeMethodImpl(context, new QtPrivate::QFunctorSlotObjectWithNoArgs(std::move(function)), -- cgit v1.2.3 From 6248bfd9e58b396cf574a16b730e6bd5d089fb0c Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 21 Feb 2020 13:56:08 +0100 Subject: Doc: Remove \pagekeywords command The command does nothing, it was not implemented by QDoc. Change-Id: Id1e5fcc02101723e9089df55d9f8949e50c89b3f Reviewed-by: Paul Wicking --- src/corelib/kernel/qmath.qdoc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc index a2e24e925b..346171f044 100644 --- a/src/corelib/kernel/qmath.qdoc +++ b/src/corelib/kernel/qmath.qdoc @@ -51,8 +51,6 @@ \value M_2_SQRTPI Two divided by the square root of pi, 2 / \unicode{0x221A}\unicode{0x3C0} \value M_SQRT2 The square root of two, \unicode{0x221A}2 \value M_SQRT1_2 The square roof of half, 1 / \unicode{0x221A}2 - - \pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm pi */ /*! -- cgit v1.2.3 From 95aec76e3169d37d4d6ba908d8a96ce578cb45e2 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 14 Feb 2020 17:45:45 +0100 Subject: Doc: Fix documentation warnings for Qt Core - QCborError: Classes cannot relate to header files; use \inheaderfile instead and link to the class from header file documentation. - QRecursiveMutex: QDoc doesn't allow shared documentation comments for duplicating \fn docs between the base and deriving classes. Remove the sharing, the function documentation is available under 'All Members' doc for QRecursiveMutex. - QMultiMap: unite() and one overload of insert() were not recognized because their definitions in the same header file interfered with QDoc - use Q_CLANG_QDOC macro to comment them out, and tag \fn comments to ensure that the function documentation is matched. Change-Id: Ic96869904a72d92453e4ffa6901000147571969b Reviewed-by: Paul Wicking --- src/corelib/kernel/qmetatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index a2b7fec5cd..71eec11e01 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -523,7 +523,7 @@ struct DefinedTypesFilter { as the QMetaType \a b, otherwise returns \c false. */ -/*! \fn bool operator!=(const QMetaType &a, const QMetaType &c) +/*! \fn bool operator!=(const QMetaType &a, const QMetaType &b) \since 5.15 \relates QMetaType \overload -- cgit v1.2.3