summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qsharedpointer_impl.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove use of 'register' from Qt.Stephen Kelly2013-06-171-5/+5
| | | | | | | | | | It is deprecated and clang is starting to warn about it. Patch mostly generated by clang itself, with some careful grep and sed for the platform-specific parts. Change-Id: I8058e6db0f1b41b33a9e8f17a712739159982450 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>
* Make it possible to use QPointer<const T>Stephen Kelly2013-02-131-1/+1
| | | | | | | | | | | | | This is possible with QWeakPointer, so allow it for migrating code too. In the process, replace the QPointerBase with a member variable for simplicity. The functionality of the QPointerBase is replaced by a TypeSelector template. Change-Id: I3b4c77bdeda2b863cc33e84a3da8a25bae928c8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-6/+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>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge branch 'stable' into devFrederik Gladhorn2013-01-071-0/+2
|\| | | | | | | | | | | | | Conflicts: tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp Change-Id: I6b8d505fc22f052c307ca27f58f7d16f98965f47
| * Don't increase the reference count if dynamic_cast failedThiago Macieira2013-01-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | If the dynamic_cast failed in QSharedPointer::dynamicCast or qSharedPointerDynamicCast, we should avoid creating the QSharedPointer that shares the weak and strong reference counts. In Qt 5, this does not imply a leak since the original pointer is stored internally for deletion. In Qt 4 it implies a leak under certain circumstances, which this change fixes. Task-number: QTBUG-28924 Change-Id: Id2de140de4cf676461e14b201ad250c53666b79d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | Add support for multiple arguments to QSharedPointer::create()Thiago Macieira2012-12-231-0/+27
|/ | | | | | | | Requires C++11 rvalue references and variadic templates so we can implement perfect forwarding. Change-Id: I62e47d1ffd0c61e8386f9f246aa79031b7430b46 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Quieten warning about uninitialized use of d pointerTobias Hunger2012-10-241-1/+1
| | | | | | | | | | We had this issue in Qt 4 before: Clang considers the use of d uninitialized in the initializer list for d. This might or might not be legal, the clang devs are divided on that topic. Let's just use a more common form and ignore the issue language lawyers. Change-Id: I3324255963a6d0f4a9057fe0d1d9ae868d3efef7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimise the deletion of a QSharedPointer with no custom deleterThiago Macieira2012-10-101-18/+33
| | | | | | | | | | | | | | | | When QSharedPointer is created with no user-specified custom deleter, instead of storing a pointer in ExternalRefCount::destroyer to a static function which, in turn, calls normalDeleter<T> indirectly (via another function pointer), specialise the CustomDeleter class and make it not store the pointer, but instead do the deleting directly. The benefits are: - the QSharedPointer's private data is smaller - there is no double-indirection via indirect jumps to the actual deleter Change-Id: Ice5653c144912efb1226e432267a047b9799aaca Reviewed-by: Olivier Goffart <ogoffart@woboq.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>
* QSharedPointer: make QT_SHAREDPOINTER_TRACK_POINTERS work with QObjectsGiuseppe D'Angelo2012-08-281-2/+2
| | | | | | | | | | | | | | | | If setQObjectShared crashes because a QObject is tracked by two different QSharedPointers, we lose the debug feature offered by #defining QT_SHAREDPOINTER_TRACK_POINTERS, as the check done by this define happens after the setQObjectShared call. Therefore, move setQObjectShared after the internalSafetyCheckAdd call. This is actually a noop change in 5.0, as setQObjectShared does nothing. However it prevents a bug in case the Qt 4 behaviour is brought back in some later version. Change-Id: I71340d0f878828354537762d01c46d441efc918c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Wrap QObject usage in qsharedpointer_impl.h with ifndef QT_NO_QOBJECTThiago Macieira2012-06-241-0/+2
| | | | | | | | Otherwise, bootstrapped tools like qmake and moc won't compile, unless QObject is forward-declared (which it isn't anymore). Change-Id: If67ca1cd8fdb7b29628f9dc4b454595d26a715d0 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Add some internal API for extracting a QSharedPointer<T> from QVariant.Stephen Kelly2012-06-201-1/+19
| | | | | | | | | | | | | The T must be derived from QObject, or it will fail to compile. This will allow scripting or other 'wrapping' and runtime environments like QtDeclarative to handle QSharedPointers to types derived from QObject properly. A QSharedPointer<T> can be inserted into a QVariant, and where T derives from QObject, a QSharedPointer<QObject> can be extracted from the QVariant, and its properties are then accessible. Change-Id: I68d6d89aceceb019267bd7301baa2047f9c09b90 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix access to uninitialized pointerTobias Hunger2012-06-201-1/+1
| | | | | | | | | | The C++ standard says in 9.4..2 that the object expression is evaluated, so any compliant compiler may access d. So this syntax is a bug in this place. Change-Id: I37d2c4ea54febd40410ca473c906bcb1c66c4974 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Keep the #ifdef for tracking shared pointers in a single functionThiago Macieira2012-06-121-23/+26
| | | | | | | | | | | | | | | If we have it in different functions, then different out-of-line implementations could be selected for each object file, resulting in invalid states. The error I caught was when wrapper.cpp was compiled without tracking and, therefore, did not place a call to internalSafetyCheckAdd. However, it called an out-of-line copy of QtSharedPointer::ExternalRefCountWithCustomDeleter::create, which did set the deleter to remove the safety check. Therefore, keep everything in one function. Change-Id: Ib2c6a606699db49d102704bccdd331ec22a8bd78 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Simple optimisation for the construction of a QSharedPointerThiago Macieira2012-06-121-9/+3
| | | | | | | | | | Let the constructor initialise the "value" member. In the case of create(), which already initialised "value", simply merge the two functions for more readability. Change-Id: I5638b3d42af3d0f5988f815e0f91d591fa1897a8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Use the copy & swap trick to simplify some code in QSharedPointerThiago Macieira2012-06-121-3/+4
| | | | | Change-Id: I5fa2fae19126bea60b9682ed7765681dd6da8c15 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Now merge the QtShared::ExternalRefCount class into QSharedPointerThiago Macieira2012-06-121-157/+133
| | | | | | | | | Completing the work of the previous commit: we don't need separate classes. Merge into the main class's body. Change-Id: I2f89b34cb6b7f5f9e8d8b809bebd86656f458644 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Merge QtSharedPointer::Basic into QtSharedPointer::ExternalRefCountThiago Macieira2012-06-121-54/+27
| | | | | | | | | | The basic class existed for legacy only, when internal reference counting was a goal. Since it isn't anymore, we can remove the distinction and simply merge the two classes. Change-Id: Ib7a1c4158a8d71e71fa6afa447938b8b85ddae87 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Merge two internal classes of QSharedPointer and de-virtualise themThiago Macieira2012-06-121-33/+29
| | | | | | | | | | | | | | | | | | | | | The two classes are QtSharedPointer::ExternalRefCountData and ExternalRefCountWithDestroyFn. The split existed because of what Qt 4.5 did before custom deleters existed: the ExternalRefCountData class was a virtual class that contained a destroy() virtual, which was in charge of deleting the data or returning false if it didn't. Turns out that virtual classes was a mistake. This commit de-virtualises them -- we couldn't do it in Qt 4 because of binary compatibility. This saves us one pointer-size in the size of the private, plus the fact that fewer symbols are required (there is no virtual table to be initialised). Additionaly, since a deleter is always stored with the reference count, we don't need the split between the two classes anymore. Change-Id: I1cd9400561dcee089a406a57bd856b1730f18afc Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove "delete value" from QSharedPointerThiago Macieira2012-06-121-26/+8
| | | | | | | | | | | | | | | | | | | | | | | | This allows a QSharedPointer to be used in contexts where the class in question is still forward-declared. This produced a warning in Qt 4 due to the expansion of the template, even if there was no chance of the pointer being deleted there (because the reference count could not drop to zero). Now, not only is the warning removed, but you can actually have the reference count drop to zero in a forward-declared class and it will do the right thing. That's because the deleter function is always recorded from the point of construction and we're sure that it wasn't forward-declared. The unit test for forward-declarations had to be rewritten. The previous version was passing only because the QSharedPointer object was created under the "tracking pointers" mode, which causes a custom deleter to be used in all cases. Task-number: QTBUG-25819 Change-Id: Ife37a4cea4551d94084b49ee03504dd39b8802c1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Deprecate the use of QWeakPointer to track QObjects.Stephen Kelly2012-06-071-2/+18
| | | | | | | | | | | | | | The main problem with using QWeakPointer to track QObjects is that it has API to convert to QSharedPointer, which is undefined behavior. There is no need to overload the meaning of QWeakPointer with QObject tracking. QPointer is more suitable and should be used instead. Because QPointer is implemented in terms of QWeakPointer, we need to add some overloads which are not deprecated. Change-Id: If0333e4800c9fd277629cc69185c9ca3e4e7e81d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove references to QtSharedPointer::InternalRefCountThiago Macieira2012-06-061-4/+0
| | | | | | | | | | | | | This class does not exist, is not needed and has never been published in a released version of Qt. It existed during the development of QSharedPointer, when internal reference counting (also known as intrusive counting) was a goal. That goal was abandoned when use with forward-declared classes was preferred. Change-Id: If3a5a29c07fc71e2001d6ba64b90ddd241ab8ae3 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* QSharedPointer: qHash two arguments supportGiuseppe D'Angelo2012-04-131-3/+3
| | | | | | Change-Id: I800de3fd9769e4829018360c25a8cf2ee2e2e08b Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove references to QT_NO_STL from QtCoreThiago Macieira2012-04-071-2/+0
| | | | | | | | QT_NO_STL is now no longer defined, so remove the conditionals and select the STL side. Change-Id: Ieedd248ae16e5a128b4ac287f850b3ebc8fb6181 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* QSharedPointer: add reset() member functionsMarc Mutz2012-03-161-0/+7
| | | | | | | | | | These have been added for std::shared_ptr compatibility, but in particular to allow tst_qnetworkreply && friends to drop the implicit conversions added to QSP by inheritance, so QSP can become final. Change-Id: I0f0401b02125d65622e52393b40a3b10bd9a850c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSharedPointer: remove two emtpy functions.Debao Zhang2012-03-151-5/+5
| | | | | | | | | As the comments says:they are broken by design, and replaced with other functions. The purpose of their existence is for BIC with Qt4.5. Change-Id: I9453f816a7b7c6812499b89b7c60f0fd99dea27c Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make it possible to put QObject tracked with QWeakPointer inside QSharedPointerOlivier Goffart2012-02-101-2/+6
| | | | | | | | | | | | | | | | Do that by keeping the QWeakPointer that track QObject independent of the ones that track QSharedPointer. QSharedPointer do not touch the sharedRefCount in QObjectPrivate anymore When converting a QWeakPointer constructed from a QObject to a QSharedPointer, it will display a warning saying one should not do that. Task-number: QTBUG-22622 Change-Id: I3595e3e7401702410776c458687ab357ad9366ab Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.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-2/+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>
* Remove Q_CC_NOKIAX86.Robin Burchell2012-01-191-12/+0
| | | | | | | | This is no longer supported. Change-Id: Ic393bc48c4c842514da69b6696cfb62b54360070 Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Shane Kearns <ext-shane.2.kearns@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>
* Make all uses of QBasicAtomicInt and Pointer use load() and store()Thiago Macieira2011-10-031-8/+8
| | | | | | | | | | | | | | Most of these changes are search-and-replace of d->ref ==, d->ref != and d->ref =. The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to be basic, so I made it QAtomicPointer. Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6 Reviewed-on: http://codereview.qt-project.org/5030 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+898
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12