summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject_impl.h
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Remove level 4 compiler warnings from MSVC.David Schulz2014-03-151-0/+2
| | | | | | | | | | Task-number: QTBUG-7233 Change-Id: I52067e3a22e98a62fd87415906e54a54ff2d6b49 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Dave McClelland
* Fix compilation with MSVC2013 & C++11 supportMichał Urbańczyk2013-11-211-0/+2
| | | | | | | | | | | | See Variadic templates issue: https://connect.microsoft.com/VisualStudio/feedback/details/801828/c2143-error-when-compiling-c-code-with-variadic-templates Task-number: QTBUG-34705 Change-Id: I733f1451f6d1e9b958c3a76998810fcff3fe779b Reviewed-by: Yuchen Deng <loaden@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Use Q_STATIC_ASSERT to report error about missing Q_OBJECTOlivier Goffart2013-09-141-1/+0
| | | | | | | | | | Q_STATIC_ASSERT gives better error with C++11 enabled. Aslo the qt_check_for_QOBJECT_macro had warning on some compiler since it used null reference Change-Id: Ic6115da800064b00c50a5762f0b79f5f656bf750 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark all qtbase headers that aren't cleanThiago Macieira2013-03-031-0/+5
| | | | | | | | | | | | | | | | QtCore has a few headers that, though public, aren't meant to be included directly. Those are the atomic headers, the three _impl.h headers and qt_windows.h. QtGui includes two OpenGL headers that don't compile on their own. Other libraries should not have headers like that (but they do, something we need to fix eventually). Change-Id: I55e4eb057748f47df927ee618f9409acbc189cc1 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-02-141-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/concurrent/doc/qtconcurrent.qdocconf src/corelib/doc/qtcore.qdocconf src/corelib/global/qglobal.h src/dbus/doc/qtdbus.qdocconf src/dbus/qdbusmessage.h src/gui/doc/qtgui.qdocconf src/gui/image/qimagereader.cpp src/network/doc/qtnetwork.qdocconf src/opengl/doc/qtopengl.qdocconf src/opengl/qgl.h src/plugins/platforms/windows/qwindowswindow.cpp src/printsupport/doc/qtprintsupport.qdocconf src/sql/doc/qtsql.qdocconf src/testlib/doc/qttestlib.qdocconf src/tools/qdoc/doc/config/qt-cpp-ignore.qdocconf src/widgets/doc/qtwidgets.qdocconf src/xml/doc/qtxml.qdocconf Change-Id: Ie9a1fa2cc44bec22a0b942e817a1095ca3414629
| * Fix copy-paste errors in QtPrivate::ConnectionTypesOlivier Goffart2013-02-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | That resulted in error such as: qobject_impl.h(82) : error C2078: too many initializers This should have been tested by tst_QObject::connectManyArguments, but the test did not work because the detection of defined QMetaType was broken for const references. That will be fixed in a latter commit. Task-number: QTBUG-29130 Change-Id: I78514c251358c0e8adf33af724d87ab114230cd3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
|/ | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QSlotObjectBase: make 'impl' and 'ref' privateMarc Mutz2012-08-261-7/+10
| | | | | | | | | | | | This allows to fold the deref() and the destroy() operations into one, destroyIfLastRef(). The member variables were renamed since there's now a member function of the same name (ref()). Change-Id: Ib94416d9e658065bbf5d3711ecafaf0eb063af17 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QSlotObjectBase: make Operation enum protectedMarc Mutz2012-08-261-3/+5
| | | | | | | | | We don't want people to go and call through the function pointer directly. Change-Id: I386645239974f008d513eaa62593c1141b294b60 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QSlotObjectBase: remove misleading commentMarc Mutz2012-08-261-1/+1
| | | | | | | | | | | | These constructors might not benefit from being constexpr (as the objects are only created on the heap), so don't suggest so. There's no disadvantage of them begin constexpr, but their constexpr'ability depends on whether QAtomic has a constexpr constructor, and the added complexity of finding that out isn't worth it. Change-Id: I089a29dcb98ba935c339dce09d71f283522a9afd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QSlotObjectBase: re-enable tail-call optimisation in impl()Marc Mutz2012-08-151-19/+19
| | | | | | | | | | | | | | | | | | | | | Two of the three operations in impl() return void, among them the most common one, call(). Having impl() return bool prevents tail- call optimisations for these. Fix by passing the bool return value for Compare as an out-parameter. Results in a nice decrease in text size (GCC 4.8-pre -O2 -std=c++11, stripped): text data bss dec hex filename 507343 13984 48 521375 7f49f tst_qobject (old) 505551 13984 48 519583 7ed9f tst_qobject (new) Reported-by: Thiago Macieira <thiago.macieira@intel.com> Change-Id: I7538c5b3f0992970c089e44f07244e6b62794a1d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QSlotObjectBase: combat virtual function "bloat"Marc Mutz2012-08-151-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In C++, the compiler creates extra functions and data for classes with virtual functions. This can lead to "virtual function bloat": http://www.boost.org/doc/libs/1_47_0/doc/html/function/misc.html#id1382504 This is especially true when the number of instances is of the same order of magnitute as the number of derived classes, such as is common with type erasure techniques. One such case is the QSlotObjectBase hierarchy, which this patch tackles. The mechanics of this optimisation are simple: re-implement the virtual function call mechanism by hand, with function pointers. But we go one step further and collapse the vtable into a single pointer to a function that implements all three currently-defined operations, swtching on an 'int which' argument. This even allows us to extend this in a BC way, should that become necessary later, by adding a new Operation and using the void** argument to transport arguments, if any. This approach was inspired by: Ulrich Drepper: How To Write Shared Libraries, Section 2.4.4 http://www.akkadia.org/drepper/dsohowto.pdf Also move the QSlotObjectBase hierarchy out of QObject so as not to export all the derived classes. This was pointed out in review by Thiago. Results (Linux amd64, GCC 4.8-pre -O2 -std=c++11, stripped): size tst_qobject* text data bss dec hex filename 523275 21192 48 544515 84f03 tst_qobject (old) 507343 13984 48 521375 7f49f tst_qobject (new) relinfo.pl tst_qobject* (old) tst_qobject: 473 relocations, 0 relative (0%), 240 PLT entries, 240 for local syms (100%), 0 users (new) tst_qobject: 323 relocations, 0 relative (0%), 238 PLT entries, 238 for local syms (100%), 0 users Change-Id: I40ad4744dde8c5c29ef62ed2d82d4b1ede178510 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Split qobject_impl.h into qobjectdefs_impl.hKent Hansen2012-04-251-425/+0
| | | | | | | | | | | | | | | | | | | This is done to make QtPrivate::FunctionPointer available to the QMetaMethod declaration in qmetaobject.h (which already included qobjectdefs.h, since that's where QMetaObject is declared), so that the new template-based QMetaMethod::fromSignal() function may be implemented. The logic for statically generating the array of qMetaTypeId (used by the template-based QObject::connect()) remains in qobject_impl.h, since it's not needed for QMetaMethod::fromSignal(). Moreover, moving that code would introduce a circular dependency, since qmetatype.h as of commit 194674044693d6b101c3dc2f4784718540d343a4 now includes qobjectdefs.h. Change-Id: I36c35041e0c6661c3cf523684177a0b6c19e2d35 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* RemoveRef should not remove the constOlivier Goffart2012-02-261-1/+0
| | | | | | | | | This does not fix anything, because AreArgumentsCompatible already do all the type checks. But it make RemoveRef consistant with std::remove_reference Change-Id: Ic42c872356172d7f5ea10de050254b5d10e50a6e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Better error reporting in case of connection failure.Olivier Goffart2011-12-201-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use Q_STATIC_ASSERT_X give a better error message. If C++11 is used, you get the string in the error. Else, clicking on the QStaticFailure error still shows you the string in the qobject.h source code) And report better failure if the return types do not match. (Without the static assert, you would still have a compilation error, but in an unrelated place, with no reference to the actual connect() call. The error was thrown from the virtual call QSlotObject::call, without saying where it was instantiated) Previously the error was relying on the existence of a type inside CheckCompatibleArguments, but the Q_STATIC_ASSERT requires a bool (hence the introduction of CheckCompatibleArguments::value) There also was a typo in the return value of AreArgumentsCompatible::dummy that made that code not work, and that error not be reported. (Instead, the error was reported when QObjectSlot::call is instantiated) Specialization of AreArgumentsCompatible for the void type have been added because if the return value of a signal or slot is void, the connection should work. Change-Id: I5a93ec787ce2a4b94a26630ca31d5001cd294e4d Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Avoid variable shadowing in qobject_impl.hKent Hansen2011-12-081-1/+1
| | | | | | | | | Some people like to build their Qt-based projects with -Wshadow -Werror, and since qobject_impl.h is included from a public Qt header, their build breaks. Change-Id: I5d8a5ee1937092149a18c0ff66a723f5bfc9ffc3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support for up to 6 arguments in the new connection syntaxOlivier Goffart2011-11-301-0/+139
| | | | | | | For compilations without variadic template support Change-Id: I78af4f6022ad7a0923e5c5788a34eb7d834f50f3 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Fix Qt::QueuedConnection when signal has a return valueOlivier Goffart2011-11-301-2/+4
| | | | | | | | | | For queued connections, the args[0] is set to null as it make no sens to forward the return value to the signal. So we need to check in the operator, that the pointer is not null. (container.data is args[0]) Change-Id: I80bde66f1ec19de0f4962c80e5b2797d2819075c Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Add support for QueuedConnection when connecting using the new syntaxOlivier Goffart2011-11-251-0/+37
| | | | | | | QMetaCallEvent now can handle a pointer to QSlotObjectBase Change-Id: I94da1e68ce9bb1fd96a9ae013a389552eb625faa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* New QObject connection syntaxOlivier Goffart2011-11-251-0/+354
In addition to the old connection syntax, you can now connect using function pointers. connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue ); You can connect also to functor or C++11 lambdas The connections are now type safe (no more problems with namespaces or typedefs). Implicit type conversion is also supported. The new syntax forces us to change the meaning of signal form protected to public, in order to be able to access the signal's address everywhere The way it works is by introducing new overload of QObject::connect that take function pointer as parametter. Those new overload are template function, that are implemented inline. The actual implementation is in QObject::connectImpl which take a QObject::QSlotObject* as parametter for the slot. That slot object contains a virtual function which call the slot which has to be implemented in the header as it depends on the template parametter. So the internals of QObjectPrivate::Connection will store this QObjectSlot* in order to be able to make the call. You can read a full description here: http://developer.qt.nokia.com/wiki/New_Signal_Slot_Syntax History of commits before it was imported on gerrit: https://qt.gitorious.org/~ogoffart/qt/ogoffarts-qtbase/commits/qobject_connect_ptr Thread on the mailing list: http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000796.html http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-September/001248.html (The discussions on the mailing list were about trying to find a solution that do not need making signals public, but no user friendly solution was found) Note: support for QueuedConnection, and the symetric QObject::disconnect is added in another commit. Qt::UniqueConnection is not supported yet in the new overload. Change-Id: I67d08436b0720e7f2992be9f7e34770960fa58fa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>