summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* QtCore: make all Q_DECLARE_SHARED types nothrow move-assignableMarc Mutz2015-06-303-8/+9
| | | | | | | Excepting QDebug, which doesn't have value semantics. Change-Id: I43757ef7bba4c1f5b6de9144f12b38ce840cd9f9 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Use QVector::reserve() all over the place.Sérgio Martins2015-06-293-0/+3
| | | | | | | | | | | | Reduces internal memory fragmentation. The search criteria was: QVector::append(), QVector::push_back(), QVector::operator<<() and QVector::operator+=() calls inside for, do and while loops. Statements inside ifs and out of loops weren't considered. Change-Id: Ie5aaf3cdfac938994e6e5dfa5f51de501ed79a0c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QWeakPointer: remove misleading Q_DECL_CONSTEXPRMarc Mutz2015-06-281-1/+1
| | | | | | | | | | Adding constexpr there is allowed, because QWeakPointer is a class template. But in 100% of cases, it will be dropped, because the destructor is not trivial. So, don't mislead users and devs to think that any or even all QWeakPointers could ever be constexpr. Change-Id: Ia50aad4d6c4fb724254308150124c666e82ef817 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QCommandLineOption: Q_DECL_NOTHROW -> Q_DECL_NOEXCEPTMarc Mutz2015-06-281-1/+1
| | | | | | | | | | In IsInvalidName::operator(), marked as _NOTHROW, we're calling qWarning(), which, of course, _can_ throw. We don't care in that case, but then we musn't use _NOTHROW, which causes UB on MSVC, but _NOEXCEPT, which causes std::terminate to be called. Change-Id: I18f74546ea3b388495fdb173d3abd9a162fb78a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSharedPointer: destroy LHS on move assignmentMarc Mutz2015-06-271-1/+2
| | | | | | | | | | | | | | | | | Howard Hinnant is right: just swapping may keep a resource alive too long. The problem with replacing swap(other) was that the naïve approach: clear(); swap(other); is not safe for self-assignment. Taking a cue from the default std::swap() implementation, and the copy-swap idiom, a self-assignment-safe version is QSharedPointer moved(std::move(other)); swap(moved); which is to what I changed the implementation now. Change-Id: I589fdae50ae22b95350db8250b02d983dc8487a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: Introduce constFirst() and constEnd()Sérgio Martins2015-06-272-2/+24
| | | | | | | | | | Allows to easily prevent detaching in common code like: getList().first() [ChangeLog][QtCore][QList] Added the convenience constFirst and constLast functions. Task-number: QTBUG-46026 Change-Id: I51ecb51fe91fc7d993ad35b5c7392f4da88e5f7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMap: use constrained templates instead of static-ifsMarc Mutz2015-06-221-29/+25
| | | | | | | | | Avoids warnings about constant expressions in ifs. Task-number: QTBUG-46649 Change-Id: I56adf8e80091330d2e97327df7751e57411fbd70 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* doc: Fix qdoc errors in qstring.cppMartin Smith2015-06-221-3/+3
| | | | | | | | Fixed a few qdoc errors. Change-Id: I9ede1c1d3b22e9613978e31722c8140ae966194e Task-number: QTBUG-46796 Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
* doc: Add missing comment delimiterMartin Smith2015-06-221-0/+1
| | | | | | | | | This prevents qdoc from getting lost and reporting extraneous errors. Change-Id: I8edf11dec67c39d7aa314fe6748acf6df4e646c8 Task-number: QTBUG-46794 Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
* QCommandLineOption: prevent aggressive inliningMarc Mutz2015-06-201-0/+2
| | | | | | | | | | | | | There is a good chance that in every program, command line options that have only one name and those that have multiple names are used. Make better use of the icache by not inlining the Private ctors into the QCommandLineOption ones. Saves 400B in text size on Linux GCC 4.9 C++11 release builds. Change-Id: I6247d4a2330c5fff75d06f5a40223d972b267e85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineOption: optimize ctorsMarc Mutz2015-06-191-31/+48
| | | | | | | | | | | ...by moving common code into the Private ctor, and catering for C++11 move semantics a bit. Saves ~1.5KiB in text size on Linux GCC 4.9 C++11 release builds. Change-Id: I52ed7e47f76b69500a871844c0920e27fe51a127 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringRef: add truncate()Marc Mutz2015-06-192-1/+17
| | | | | | | | | | Missing part of QString API. [ChangeLog][QtCore][QStringRef] Added truncate(int). Change-Id: I49e218daf8f47fcd3dad131155e0abc8e2a133e5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMap: add const equal_range() overloadMarc Mutz2015-06-192-0/+16
| | | | | | | | | | ... to prevent detaching. [ChangeLog][QtCore][QMap] Added const equal_range() overload. Change-Id: I4b39abb8ad41ba6eaa8f9a9a74ed74ed10337dd3 Reviewed-by: Sérgio Martins <sergio.martins@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector: add move(int,int) for QList compatMarc Mutz2015-06-182-0/+23
| | | | | Change-Id: I67948621313f2e7c69abe7ef95ee82ca64c6512a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Unify QByteArray::MaxSize and MaxAllocSizeUlf Hermann2015-06-165-22/+73
| | | | | | | | | | | | | | | | | | | | | | | | We have established the maximum size qAllocMore can deal with in commit 880986be2357a1f80827d038d770dc2f80300201 and we should use it. The maximum size for byte arrays is reduced by one byte as with the previous code we could make qAllocMore produce ((1 << 31) - extra) by passing (1 << 30). That is not a problem for qAllocMore itself (as long as extra > 0) but it's hard to verify that no related code casts the total sum back to signed int, which would overflow to -1. To make the compiler inline access to the maximum size, a private enum MaxByteArraySize is provided, which can be used in internal code. This fixes the merge of commits 880986be2357a1f80827d038d770dc2f80300201 and c70658d301e274c3aaa1fb6cebe2a5e56db12779 Change-Id: Idb04856f7c2e53ef383063e7555d3083020ff2b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark unused parameters with Q_UNUSEDUlf Hermann2015-06-121-0/+3
| | | | | | | | This prevents compiler warnings on less common branches of certain ifdefs. Change-Id: I89bae68491151b21cf6887a854cc4c9f68838cf9 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* core: Add several QList::reserve() calls.Sérgio Martins2015-06-112-1/+3
| | | | | | | Reduces reallocations. Change-Id: Ib63539fb690a80245d8fe81ff8468e79ffa8e57c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-0312-52/+225
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
| * Don't assign iterator to const_iteratorSérgio Martins2015-06-021-4/+4
| | | | | | | | | | | | | | | | It should also be possible to use QT_STRICT_ITERATORS in Qt's own code base Change-Id: I0914db480d4d2b06e71e3a2588163efdd3ff6d27 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * Translate AM/PM under the QDateTimeParser context so it is consistentAndy Shaw2015-05-282-8/+9
| | | | | | | | | | | | | | | | | | | | In order to ensure that the same text will be used in both QDateTimeParser and QDateTimeEdit, use the QDateTimeParser context for the AM and PM strings. Task-number: QTBUG-251 Change-Id: I89b0809825251181440bf19cbe5828024a43acfb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
| * Fix compilation of QContiguousCache::operator=Thiago Macieira2015-05-201-1/+1
| | | | | | | | | | | | | | | | | | freeData() takes a Data*, not a QContiguousCacheData*. Task-number: QTBUG-45783 Change-Id: I96d7ac38dac24b418138ffff13d7fdf09b1d6b07 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
| * Doc: added doc to undocumented functionsNico Vertriest2015-05-186-28/+200
| | | | | | | | | | | | | | Task-number: QTBUG-36985 Change-Id: Ia98654f88cf5da77245b3fcd903b860d12862fc2 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
| * QSize, QSizeF: Add Q_REQUIRED_RESULTSérgio Martins2015-05-131-9/+9
| | | | | | | | | | | | | | | | ...to signatures matching the pattern: T T::<verb in past tense>() const; Change-Id: I75d724a3eef5cb94559e31d86914c6e0655b7f13 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * Add Q_REQUIRED_RESULT in several placesSérgio Martins2015-05-042-2/+2
| | | | | | | | | | | | Change-Id: Icda3000f1d9f0d41612a50a816aa5de5e32028d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QSet: Introduce intersects().Sérgio Martins2015-05-303-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | The pattern "mySet.intersect(other).isEmpty()" has been spotted in the wild and in Qt codebase. intersects() is much cheaper because it bails out as soon as we find one common item and doesn't do any allocations. [ChangeLog][QtCore][QSet] Added intersects(). Change-Id: I44a350dc4cdb9deb835a23eee99fc99d6ca24c82 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QHash: Add a findNode() overload that doesn't calculate hashSérgio Martins2015-05-301-8/+16
| | | | | | | | | | | | | | | | | | Needed for QSet::intersects() for optimization purposes. No need to calculate the hash when we already have it. Change-Id: I247602bb0558ca8d1fb8333de9d5f339146c576d Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QRingBuffer: merge indexOf() overloadsAlex Trotsenko2015-05-282-19/+1
| | | | | | | | | | Change-Id: Icfed4a29bc2ac95b3e0300eb4579751fe7e57e77 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Add shared implementation of a NSAutoreleasePool wrapper to qglobalTor Arne Vestbø2015-05-271-13/+1
| | | | | | | | | | | | | | | | | | | | | | We have at least 5 different (but equal) implementations of a wrapper in Qt, and some code uses explicit NSAutoreleasePools. Having a shared implementation lets us clean up things a bit and makes it easier to reason about which pools are actually needed. Change-Id: I2fd8eefc3ae7308595ef9899b7820206268362a5 Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | QVector: add const first/last gettersGiuseppe D'Angelo2015-05-262-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | Convenience to avoid annoying detaching (instead of using at()), especially on temporary vectors (returned by functions or so). [ChangeLog][QtCore][QVector] Added the convenience constFirst and constLast functions. Change-Id: If61b1f0096f6a7a1c9074340e237cc2376ce3d18 Task-number: QTBUG-46026 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Deinline QRingBuffer classAlex Trotsenko2015-05-203-243/+351
| | | | | | | | | | | | | | | | Reduce the size of .text section in QtCore by 4.5KB and in QtNetwork by 26.5KB. Change-Id: If7998776166b9681c1e4b24c51d40444aa996d7a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | QList: partially revert ab8366b5923ec0feb730df98040885669f7bbe38Marc Mutz2015-05-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That commit removed the user-defined copy constructors, under the assumption that this would be ok for these non-exported classes. But the change is still BiC, because it turns the iterators into trivial types, which changes the way they are passed into functions by value. So, delay the change until Qt 6. Change-Id: I8065ff1ff78f5722505328447f2496777d1e8957 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Fixing the build of the SIMD support for WEC2013.Bjoern Breitmeyer2015-05-121-1/+3
| | | | | | | | | | | | | | Change-Id: Ib0dd8d34f0a5d68acb1efbc37680165e7d7933bd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Gunnar Roth Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Check the maximum size of a QByteArray more preciselyAlex Trotsenko2015-05-111-3/+4
| | | | | | | | | | | | | | | | | | Also document that the QByteArrray::MaxSize takes a trailing '\0' into account. Change-Id: I89e9a0d1a80a49b33efbac16ff7aa2a98f0e5670 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add qHash(QRegExp) and qHash(QRegularExpression)Marc Mutz2015-05-054-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QReg*Exp*s can be compared for equality, so qHash should be overloaded, too. There was a (poor) private implementation of qHash(QRegExpEngineKey) already, which has now been replaced with a better one (the old one didn't take into account all the fields that make up equality, producing unnecessary collisions). [ChangeLog][QtCore][QRegExp] Added qHash(QRegExp). [ChangeLog][QtCore][QRegularExpression] Added qHash(QRegularExpression). Change-Id: I1d22fbcc0508018a3f94b4c24571b13ba6e07df2 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | Merge remote-tracking branch 'origin/5.5' into HEADSimon Hausmann2015-05-041-1/+2
|\| | | | | | | Change-Id: I487a4b7c05687a10c498ac219c31367d4db6fbc0
| * QRegularExpression: add error strings from PCRE 8.37Giuseppe D'Angelo2015-05-011-1/+2
| | | | | | | | | | | | | | Change-Id: Id62abd91c1584e4e63b95afec0520995125fe807 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-273-17/+16
|\| | | | | | | | | | | | | | | Conflicts: src/tools/qdoc/tree.cpp tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: Iaa78f601a63191fa643aabf853520f913f2f0fdc
| * Doc: Bring QSizeF/QPointF::isNull() documentation up to dateTopi Reinio2015-04-272-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | Since Qt 5.0 (commit 09dd19df) sign is ignored when testing whether a QPointF or QSizeF is null. This updates the documentation accordingly. Change-Id: I3de1c748f3caa63b8bd8990006de5ba572eac83e Task-number: QTBUG-45669 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
| * QVector: Save one copy-CTOR call if we don't reallocSérgio Martins2015-04-241-5/+12
| | | | | | | | | | Change-Id: Ie0f2eb922500bc3d76852939cf2c5d28d65a43ae Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QLocale: Exclude null-byte in QString generated from script_code_list.Milian Wolff2015-04-241-1/+1
| | | | | | | | | | Change-Id: I2b9b85dd052360ea6bd96f18180b1b97cf4daaeb Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-228-37/+32
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/gui/painting/qdrawhelper.cpp src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/plugins/platforms/xcb/qxcbwindow.h src/testlib/qtestblacklist.cpp src/tools/qdoc/node.cpp src/tools/qdoc/node.h tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
| * qdoc: Remove #ifdef Q_QDOC for uses of QPrivateSignalMartin Smith2015-04-201-20/+4
| | | | | | | | | | | | | | | | | | | | | | | | Signals marked with QPrivateSignal had the QPrivateSignal marker ifdefed out for qdoc. This is no longer necessary, so the #ifdefs are removed. Change-Id: Idb334ed311c6ed6883d7b7b5a3fcdede60c4a1f8 Task-number: QTBUG-45535 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
| * QScopedValueRollback: add two strategic qMove()sMarc Mutz2015-04-161-2/+2
| | | | | | | | | | | | | | | | Use moves instead of copies when the rhs is no longer needed afterwards. Change-Id: If053bfce03b886099688452ada74f6a6f36db5c2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * QScopedValueRollback: use ctor-init-listMarc Mutz2015-04-161-4/+2
| | | | | | | | | | | | | | Avoids calls to the default ctor for member 'oldValue'. Change-Id: Ieb9570b74e4a46b28c04625fac3ce267074c4a76 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * QList: make QListSpecialMethods dtors protectedMarc Mutz2015-04-163-1/+14
| | | | | | | | | | | | | | | | | | QList publicly inherits from QListSpecialMethods. Thus, any specialisation of QListSpecialMethods should make their destructor protected, to avoid deletion through a pointer to QListSpecialMethods invoking UB. Change-Id: I7e317606f84826cc0faf1bfc05dee97da6eaf2eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Merge remote-tracking branch 'origin/5.4' into 5.5Liang Qi2015-04-153-10/+10
| |\ | | | | | | | | | Change-Id: I004854a25ebbf12b1fda88900162fe7878716c58
| | * Doc: Fix using Apple-related terminology in Qt CoreAlexander Volkov2015-03-313-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the name "OS X" instead of "Mac OS X", "Mac OS" and "OSX", and mention iOS. Replace "Carbon Preferences API" by "CFPreferences API" in the QSettings documentation. Change-Id: Ia7f9fb874276c7c445a1649df521b96ff43daa0c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | | Add qHash(QVector)Marc Mutz2015-04-202-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | QVectors can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtCore][QVector] Added qHash(QVector). Change-Id: I2aacce55d416abf2492631a504a02c6e8fc4ff1c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Add qHash(QList)Marc Mutz2015-04-202-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | QLists can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtCore][QList] Added qHash(QList). Change-Id: I9ad91811f12479764cc17d87192539612ceb0b4c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Remove <qhash.h> where it's not usedMarc Mutz2015-04-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5) in public headers. Change-Id: I6117e8a6b11200d2f1a0a94a0e87d5c27538218e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>