summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qtmetamacros.h
Commit message (Collapse)AuthorAgeFilesLines
* Add Q_OBJECT_NO_OVERRIDE_WARNING for MSVCJoni Poikelin2023-12-011-0/+2
| | | | | Change-Id: I5fc19c03eae3b7ea1aab83c5e3c978d57970bd25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace usages of Q_CLANG_QDOC with Q_QDOCLuca Di Sera2022-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | To allow the user to customize the C++ code that QDoc sees, so as to be able to work-around some limitations on QDoc itself, QDoc defines two symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an entire execution of QDoc. At a certain point in time, QDoc allowed the user the choice between a custom C++ parser and a Clang based one. The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol would be defined only when the Clang based parser was chosen. In more recent times, QDoc always uses a Clang based parser, such that both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent. To avoid using different symbols, and the possible confusion and fragmentation that derives from it, all usages of Q_CLANG_QDOC are now replaced by the equivalent usages of Q_QDOC. Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QPrivateSignal: disable implicit conversions from initializer_listGiuseppe D'Angelo2022-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The whole point of QPrivateSignal is to forbid anyone but the class itself from emitting a certain signal. This is a "workaround" introduced in Qt 5.0, due to the fact that the PMF syntax for connections requires users to take the address of a signal, and that is only possible if the signal itself is public. (In fact, signals were protected in Qt 4.) The Q_OBJECT macro defines the private QPrivateSignal class. A QObject subclass that wants to "protect" its signal emissions can declare a signal carrying an argument of type QPrivateSignal: signals: void aSignal(int, QPrivateSignal); If the class itself wants to emit the signal, it can do so: emit aSignal(42, QPrivateSignal()); But if "someone else" wants to, they can't use the QPrivateSignal type because it's private. emit obj.aSignal(42, SomeClass::QPrivateSignal()); // ERROR Here's a hair in this soup: list initialization. If a braced-init-list is used, [over.ics.list] simply *ignores* access control. This allows an "untyped" initializer-list to match QPrivateSignal and perform aggregate initialization: emit obj.aSignal(42, {}); // works! This kind of defeats the whole purpose. Therefore: make QPrivateSignal not an aggregate and give it an explicit default constructor, disabling copy-list-initialization for it. This means that using `{}` will fail to compile (class is no longer an aggregate, a constructor must be selected, and copy-list-initialization will not select an explicit constructor). This isn't a complete fix by any means. There's always the possibility of using enough template magic to extract QPrivateSignal's type (e.g. as a local alias) and then create an object of that type; but that sounds extremely unlikely to be happening "by accident" (whilst it's super-easy to just type {} as the argument and not realize that you were not supposed to do so). [ChangeLog][QtCore][Potentially Source-Incompatible Changes] It is no longer possible to use `{}` to construct a QPrivateSignal object (specifically, QPrivateSignal's default constructor is now explicit). This means that emitting a signal that carries a QPrivateSignal argument (i.e. a "private signal") cannot any longer be done by using something like `emit aSignal({})`; instead, such usages must be ported to `emit aSignal(QPrivateSignal());` or equivalent. Change-Id: Iac379aee3a8adca5a91d5db906a61bfcd0abc89f Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-111-8/+3
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix -Wsuggest-override warnings from Clang 11+Kevin Funk2022-02-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, Clang versions greater than 11.0.0 emitted -Wsuggest-override warnings whenever the Q_OBJECT macro was used. Excerpt from compiling GammaRay against Qt 6, using Clang 13.0.0: ``` .../qtbase/src/corelib/io/qfile.h:96:5: warning: 'qt_metacall' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] Q_OBJECT ^ .../qt5/qtbase/src/corelib/kernel/qtmetamacros.h:166:17: note: expanded from macro 'Q_OBJECT' virtual int qt_metacall(QMetaObject::Call, int, void **); \ ^ .../qt5/qtbase/src/corelib/io/qfiledevice.h:54:5: note: overridden virtual function is here Q_OBJECT ^ .../qt5/qtbase/src/corelib/kernel/qtmetamacros.h:166:17: note: expanded from macro 'Q_OBJECT' virtual int qt_metacall(QMetaObject::Call, int, void **); \ ^ ``` This was also discussed on the QtCreator mailing list: https://www.mail-archive.com/qt-creator@qt-project.org/msg08500.html Pick-to: 6.2 6.3 Change-Id: I149782472ce8a2e30ed8062ada460c39926f1613 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live Q_GADGET_EXPORT!Marc Mutz2021-11-271-4/+7
| | | | | | | | | | | | | | | | | | | | | | Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET allows passing an export macro. This is useful to avoid exporting the whole class just to get the staticMetaObject hidden therein exported. Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject subclasses, being polymorphic, always need to have a class-level export macro (to export their vtable), but while that technique also works for value classes (the Q_GADGET audience), it is not desirable for them, because it makes inline functions exported in Windows debug builds, which is not what we want, because it needlessly restricts what you can to with the inline functions (e.g. remove). [ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT for Q_NAMESPACE). Fixes: QTBUG-55458 Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove QNotifiedProperty and Q_PRIVATE_QPROPERTYLars Knoll2020-09-021-35/+0
| | | | | | | | | | | | | And all related functionality. This is being replaced by Q_BINDABLE_PROPERTY and Q_OBJECT_BINDABLE_PROPERTY in the next few commits. The new infrastructure coming will play nicer along with the existing property system. Commented out some autotests, that will get reimplemented with the updated infrastructure. Change-Id: I50c30bd4d5c6c6b6471f8eb93870e27d86f5a009 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-4/+4
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QObject/Q_OBJECT: remove deprecated old APIEdward Welbourne2020-08-141-2/+0
| | | | | | | Since 5.0, trUtf8(), qFindChild() Change-Id: I7bc0d125f92faebf24a422c1aac528a3f4687434 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove deprecated empty macroLars Schmertmann2020-07-021-3/+0
| | | | | Change-Id: Ib2a646ee22a7f97dae584e6f068f17378fe2b494 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* moc: Fix QProperty code generationFabian Kosmale2020-06-251-3/+3
| | | | | | | | | | | | | | | | This addresses two issues: 1. The generated code for QNotifiedProperty<T, ...> was broken when T is a pointer. Notably, const S* & is not a constant reference to S*. This is addressed by consistently using T const& instead of const T&. 2. The Q_PRIVATE_QPROPERTY approach assumed that the property name and the getter are equal. This does break when they are not, and we are unable to change either of them due to API compatibility concerns. An example of this would be QQuickItem's parent property with a parentItem getter. Therefore, we now allow the usage of NAME to override the name of the property. Change-Id: Idf2e85576c74371b5b0f6db15dbe6f2d17c5e33d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Cleanups in QMetaPropertyFabian Kosmale2020-06-111-1/+1
| | | | | | | | | This changes the layout of the meta object data, so also bump the meta object revision. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Change-Id: I176fb16c207e8ebe59e358e69554be813406232f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Attempt to squeeze unionized fake qproperty members even furtherSimon Hausmann2020-04-301-2/+9
| | | | | | | | | ... by using the [[no_unique_address]] attribute, if available, instead of the union. Change-Id: Iab4db7039f1140a0005c7dd2fb6e08597ceec8f5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Provide a way of exposing private QProperties with a fake APISimon Hausmann2020-04-301-0/+32
| | | | | | | | | | | | The API reduces the amount of manual plumbing required to offer a conceptual property through the traditional setter/getter API as well as through QProperty<T> API. Since the latter would require inlining the type and thus making it impossible to add new properties without breaking binary compatibility, this patch introduces a fake API that behaves similar but does not contain the property by value. Change-Id: Ib9bccd867f0e4e36a520e5583ba348e728284253 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Extend revision markers to allow for major and minor versionUlf Hermann2020-02-071-2/+2
| | | | | | | | | | | | | As we want Qt's own revisions to follow the Qt versioning scheme, we need to allow for the minor version to reset to 0 now. In order to facilitate this, we interpret the argument passed the current Q_REVISION macro as major version and allow for an optional minor version. Both are encoded it into the resulting revision number. Change-Id: I3519fe20233d473f34a24ec9589d045cdd162a12 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Introduce Q_MOC_INCLUDEOlivier Goffart2020-01-171-0/+1
| | | | | | | | A new macro that can be added in the header file parsed by moc to tell moc to include that file in the generated file Change-Id: I03ad702c3fcd8380371015f226ee4b7456daf132 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use Q_NAMESPACE for the Qt namespace, and remove the old moc hack to support itOlivier Goffart2019-12-061-0/+233
Since I can't #include qobjectdefs from qnamespace because of circular dependency, move the Qt macro in the qtmetamacros.h header. Deprecate QObject::staticQtMetaObject since now one can just use Qt::staticMetaObject Change-Id: I11982aa17c2afa2067486b113f8052672f3695eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>