summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-13/+13
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Move literal code block to a separate fileCristian Maureira-Fredes2018-10-151-22/+6
| | | | | | | | | | | We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QHash: Remove reference to Qt3's QDict implementationhjk2018-07-241-3/+2
| | | | | | | | | | While it is still formally correct, it does not add much value anymore. Change-Id: I32431e3e73f3ca662dc4beb754f53449692c56a9 Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com> Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* doc: Correct remaining qdoc warnings in qhash.cppMartin Smith2018-01-041-5/+17
| | | | | | | | Added template clause to several qHash() functions and created a \typedef comment for QHash::const_key_value_iterator. Change-Id: Id56191f69bf9f36e606101e46bf1dfa528d88e09 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* doc: Fix three "Cannot tie" errorsMartin Smith2017-12-021-1/+1
| | | | | | | | | | Two of the three functions were for functions that should not be documented. The third was a function protected by #ifndef Q_OS_DARWIN, which required a test of Q_CLANG_QDOC in the header and cpp files. Change-Id: Id2ab3e4f2ea896dc628a622de2e80a19c18eb9fe Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Add template text to \fn commands in container classesMartin Smith2017-12-011-125/+125
| | | | | | | | | | The \fn commands were not recognized by clang-qdoc because the template stuff was missing from the \fn commands. This update adds the correct template text and parameters. It eliminates nearly 2000 qdoc warnings. Change-Id: Ibe047424396a8f99f8bd64efea1b0d8cc7c7527d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-11-091-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qwindow.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/windows/qwindowssystemtrayicon.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ifa515dc0ece7eb1471b00c1214149629a7e6a233
| * qGlobalQHashSeed: initialize the seed before returning itThiago Macieira2017-11-041-0/+1
| | | | | | | | | | | | | | | | | | If you had never used QHash before, this function returned -1. That's not useful if you're trying to implement your own QHash that uses Qt's global seed. Change-Id: Ib0e40a7a3ebc44329f23fffd14b2e875b970a55c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QRandomGenerator: add system() and global()Thiago Macieira2017-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now,this does really nothing. This commit is just to allow us to transition the other modules (besides qtbase) to use the syntax that will become the API. I've marked three places to use the system CSPRNG: 1) the QHash seed 2) QUuid 3) QAuthenticator I didn't think the HTTP multipart boundary needed to be cryptographically safe, so I changed that one to the global generator. Change-Id: Ib17dde1a1dbb49a7bba8fffd14ecf1938bd8ff61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QRandomGenerator: update API to better nameThiago Macieira2017-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | "generate" is better than "get", and we already have "generate(it, it)" which uses std::generate(). This changes: - get32() → generate() - get64() → generate64() and QRandomGenerator64::generate() - getReal() → generateDouble() Change-Id: I6e1fe42ae4b742a7b811fffd14e5d7bd69abcdb3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-08-311-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/examples.pro qmake/library/qmakebuiltins.cpp src/corelib/global/qglobal.cpp Re-apply b525ec2 to qrandom.cpp(code movement in 030782e) src/corelib/global/qnamespace.qdoc src/corelib/global/qrandom.cpp src/gui/kernel/qwindow.cpp Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08) src/network/ssl/qsslkey_openssl.cpp src/plugins/platforms/android/androidjniinput.cpp src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/widgets/widgets/qmenu.cpp tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
| * Fix error attribute(target("+crc")) is unknownPeter Seiderer2017-08-291-0/+2
| | | | | | | | | | | | Task-number: QTBUG-61975 Change-Id: I0b1b55c0737dad485b5ace8e6eb7cb842589453d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | QUuid, QHttpMultipart and QHash: use QRandomGeneratorThiago Macieira2017-06-121-38/+2
| | | | | | | | | | | | | | | | | | QRandomGenerator can produce more than 31 bits of data. And it uses /dev/urandom for us on Unix, so QHash does not need to duplicate that part. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b52a0d91f179eb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-05-071-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/network/access/qnetworkreply.cpp tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
| * Add two missing hyphensEdward Welbourne2017-04-301-1/+1
| | | | | | | | | | | | Change-Id: Ic320c96208fe7f8340c7eb9e9d068813d769056a Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Implement key-value iteratorSamuel Gaist2017-05-051-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements an iterator that returns a pair containing both the key and the value of an entry in QHash/QMap. [ChangeLog][QtCore][Containers] Added an stl-like iterator to go through QHash/QMap returning both the key and the value of the element pointed to. That lets QHash/QMap interoperate better with stl's algorithms like std::set_union. Change-Id: Idbf8a8581510b3493648c34ab04c556de9fa4aa7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QHash: make it so a zero seed selects a constant algorithmThiago Macieira2017-04-261-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | That's the only value for which we will guarantee a stable result across Qt versions and across invocations of the same application on different architectures is zero. For any other value, we reserve the right to change the algorithm. We'll now print a warning when we detect that. Task-number: QTBUG-47566 Change-Id: I27b55fdf514247549455fffd14b1135e10d24ab4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* | Allow to chain qt_hash() callsMarc Mutz2017-03-301-11/+9
| | | | | | | | | | | | | | | | | | There are some callers of qt_hash that first build a string just to hash it. By allowing to pass an initial value for 'h', we can chain qt_hash() calls to avoid having to allocate memory just to hash a two-part string. Change-Id: Ifaca82d47b2fb8c707912342c3ddd84f91e70267 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add qHash(QStringView)Marc Mutz2017-03-301-0/+14
| | | | | | | | | | | | | | | | [ChangeLog][QtCore] Added qHash(QStringView). Change-Id: I69c9203cf301fe586e924168381884aab2e19e5c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | Replace internal qt_hash(QString(Ref)) functions with one taking QStringViewMarc Mutz2017-03-301-13/+3
|/ | | | | | Change-Id: I49d07689e642d26b4bceda5cace738aadd828ce0 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* QHash: unexport the hash seed variableThiago Macieira2017-03-201-1/+1
| | | | | | | | | | | The only allowed way to access the variable is now via the public qGlobalQHashSeed and qSetGlobalQHashSeed functions. The variable was private API, so we're allowed to remove it. Task-number: QTBUG-47566 Change-Id: I4a7dc1fe14154695b968fffd14abd331e5810482 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Don't narrow lengths in qHash() implementationsMarc Mutz2017-01-311-11/+12
| | | | | | | | | | | | The crc32() functions take a size_t length, but the hash() functions wrapping them took int lengths. That makes no sense and actively hurts adding hash functions for STL types or QStringView, so port the hash() interface to size_t. Change-Id: Id303d6df4b698560fce656cec8ed693b01daac1c Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qHash(QHash) and qHash(QMultiHash)Marc Mutz2016-07-141-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | The hash function is carefully designed to give the same result as the straight-forward implementation of qHash(unordered_map), which we'll probably add at some point, namely: std::accumulate over a container of std::pair. This is one reason to use std:: and not QPair in the implemen- tation of qHash(QHash). The other is that qHash(QPair) uses a bad hash combiner, which may xor out the 'seed' from the result. We can't fix that until Qt 6, but the qHash(std::pair) overload uses the well-known boost::hash_combine algorithm (implemented in Qt as QtPrivate::QHashCombine), so we can use that. I also trust std::pair to work without problems with reference template arguments, while QPair only very recently gained a very basic auto-test for reference parameters. [ChangeLog][QtCore] Added qHash() overloads for QHash, QMultiHash. Change-Id: I90879d8a99cf1aadb6e84ecc0c3704f52f3691da Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-061-4/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf config.tests/unix/nis/nis.cpp mkspecs/unsupported/freebsd-g++/qplatformdefs.h src/corelib/tools/qdatetime.cpp src/corelib/tools/qsimd.cpp src/corelib/tools/qsimd_p.h src/network/access/access.pri src/network/access/qnetworkreplynsurlconnectionimpl.mm src/network/access/qnetworkreplynsurlconnectionimpl_p.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/printsupport/windows/qwindowsprintdevice.cpp tests/auto/corelib/kernel/qobject/tst_qobject.cpp tests/auto/network/access/qnetworkreply/BLACKLIST tests/auto/widgets/widgets/qopenglwidget/BLACKLIST Change-Id: I4b32055bbf922392ef0264fd403405416fffee57
| * Replace qUnaligned{Load,Store} with the existing q{To,From}Unalignedv5.6.1-1v5.6.1Thiago Macieira2016-05-251-4/+5
| | | | | | | | | | | | | | | | Move the Q_ALWAYS_INLINE and forcing of __builtin_memcpy to the existing functions. Change-Id: Icaa7fb2a490246bda156ffff143c137e520eea79 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-071-1/+0
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/network/access/qftp.cpp src/widgets/itemviews/qheaderview.cpp src/widgets/itemviews/qlistview.cpp tests/auto/network/access/qftp/tst_qftp.cpp Change-Id: I9f928f25d45d8944dd60bb583f649fc1615bc5d9
| * Remove empty first lines of files.Friedemann Kleint2016-04-061-1/+0
| | | | | | | | | | | | | | They might upset licensing related tools. Change-Id: I858d21fc418ba16959c88847b559b11bea29ed6b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-111-4/+4
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change partially reverts 1bfc7f68 about QT_HAS_BUILTIN define and undef in src/corelib/tools/qsimd_p.h. This change is also squashed with "Fall back to c++11 standard compiler flag for host builds" which is done by Peter Seiderer. Conflicts: mkspecs/features/default_post.prf src/3rdparty/sqlite/0001-Fixing-the-SQLite3-build-for-WEC2013-again.patch src/3rdparty/sqlite/sqlite3.c src/corelib/tools/qsimd_p.h src/gui/kernel/qevent.cpp src/gui/kernel/qwindowsysteminterface.cpp src/gui/kernel/qwindowsysteminterface_p.h src/plugins/bearer/blackberry/blackberry.pro src/plugins/platforms/cocoa/qcocoasystemsettings.mm src/plugins/platformthemes/gtk2/gtk2.pro src/plugins/styles/bb10style/bb10style.pro src/sql/drivers/sqlite2/qsql_sqlite2.cpp tools/configure/configureapp.cpp Task-number: QTBUG-51644 Done-with: Peter Seiderer <ps.report@gmx.net> Change-Id: I6100d6ace31b2e8d41a95f0b5d5ebf8f1fd88b44
| * QString, QJson, QHash: Fix UBs involving unaligned loadsMarc Mutz2016-03-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: src/corelib/tools/qstring.cpp:587:42: runtime error: load of misaligned address 0x2acbf4b7551b for type 'const long long int', which requires 8 byte alignment src/corelib/json/qjson_p.h:405:30: runtime error: store to misaligned address 0x0000019b1e52 for type 'quint64', which requires 8 byte alignment src/corelib/tools/qhash.cpp:116:27: runtime error: load of misaligned address 0x2b8f9ce80e85 for type 'const qlonglong', which requires 8 byte alignment src/corelib/tools/qhash.cpp:133:26: runtime error: load of misaligned address 0x2b8f9ce80e8d for type 'const ushort', which requires 2 byte alignment Fix by memcpy()ing into a local variable. Wrap this trick in template functions in qsimd_p.h. These are marked as always- inline and use __builtin_memcpy() where available in an attempt to avoid the memcpy() function call overhead in debug builds. While this looks prohibitively expensive, from the pov of the C++ abstract machine, it is 100% equivalent, except for the absence of undefined behavior. In one case, the cast produces a local temporary which is then copied into the function, and in the other case, that local variable comes from return value of qUnalignedLoad(). Consequently, GCC compiles these two versions into identical assembler code (only verfied for ucstrncmp, but there's no reason to believe that it wouldn't hold for the other cases, too). Task-number: QTBUG-51651 Change-Id: Ia50d4a1d7580b6f803e0895c9f3d89c7da37840c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* | ARMv8: fix crc intrinsic usage.Erik Verbruggen2016-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | ARMv8 defines the crc32 instructions as optional features. Even though the target might be ARMv8, the compiler might have been told that the target CPU doesn't support it, in which case __ARM_FEATURE_CRC32 is not defined. Subsequently, the arm_acle.h header might only define the intrinsics when __ARM_FEATURE_CRC32 is defined. Change-Id: I85efcf9efdd2e152e3f3e72310122eebf543ca3b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* | Introduce QHash::equal_range()Sérgio Martins2016-02-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | Similar to QMap::equal_range(). Will allow to easily fix inefficient code such as: foreach (auto value, hash.values(key)) { ... } [ChangeLog][QtCore][QHash] Added QHash::equal_range() Change-Id: I6e19e25de632e897ad83d3141d9d07f0313f7200 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-02-111-1/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qfilesystemwatcher_win.cpp src/corelib/plugin/plugin.pri src/plugins/platforms/cocoa/qcocoaaccessibility.mm tests/auto/corelib/tools/qlocale/tst_qlocale.cpp Change-Id: Id6824631252609a75eff8b68792e4d10095c8fc1
| * Doc: corrected minor link issuesNico Vertriest2016-02-051-1/+1
| | | | | | | | | | | | Task-number: QTBUG-43810 Change-Id: I98eafe0c7ed55f309640e8495c83ffcef355aa08 Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
| * Revert "Fix deadlock when setting environment variables."Oliver Wolff2015-11-241-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5b62a5e7aabcc818408f2fe28b9760082f474def. This commit is reverted due to two reasons: 1) It was written incorrectly and does not work as is. The ifdefs should be ifndefs. In its current state, it does the exact opposite of what it is supposed to be doing. 2) There is another environment access inside qsimd.cpp (which checks QT_NO_CPU_FEATURE). This access causes the app to hang. All in all that approach is not sustainable as we might get bitten by environment access again and again. Instead we should use another environment container or use a recursive mutex for WinRT and Windows CE. Task-number: QTBUG-49529 Change-Id: Iaca76404dc1023551a7c25489a609681135765fd Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Samuel Nevala <samuel.nevala@intopalo.com>
| * Fix deadlock when setting environment variables.Samuel Nevala2015-11-231-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt uses QHash as the container for faking environment variables on Windows Runtime and CE. Environment variable manipulation functions are protected by mutex. Accessing the QT_HASH_SEED environment variable inside QHash can lead to situation where qputenv() call leads to qgetenv() call and that leads to a deadlock. Since the application environment is faked anyway, drop support for QT_HASH_SEED and ifdef that functionality out on those platforms. Documentation is updated to reflect changes. Task-number: QTBUG-49529 Change-Id: I1b1c28cb0b041fe2a63ca3dce57068fcb46505a7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
* | Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
| | | | | | | | | | | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | ARMv8: Update qHash for strings to use the CRC32 instructionErik Verbruggen2016-01-131-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | Same as the SSE4.2 implementation: use the (optional) ARMv8 crc32[bhwd] instruction to calculate hashes for strings. For Aarch64, support for the instruction is dynamically detected. For a 32bit ARM binary, dynamic detection is only done when the compiler is explicitly told to target ARMv8. When telling the compiler to target an other/older version, the crc32 code is not compiled. Change-Id: I51ebc1a4545dede4988247e75043f29a64c2a6c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add qHash(std::pair)Marc Mutz2015-12-301-0/+17
| | | | | | | | | | | | | | | | | | | | | | We already include <utility> in <qglobal.h>, so we might as well provide a qHash() overload for std::pair. [ChangeLog][QtCore] Added qHash(std::pair), defined in <QHashFunctions>. Change-Id: I0f61c513e82e05ce9d2e56bcf18f3be9e2da4da9 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QHash/QSet: add erase(const_iterator)Marc Mutz2015-12-191-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | This is the signature the functions have in C++11. For the std containers, this is just convenience, but for Qt containers with their implicit sharing problem, the combination of erase() with constFind() can delay a detach until absolutely necessary. [ChangeLog][QtCore][QHash/QSet] Added erase(const_iterator). Change-Id: I2fc841c664cd7515b0f56fd7210fcd17c37f9014 Reviewed-by: David Faure <david.faure@kdab.com>
* | Use Q_UNLIKELY for every qFatal()/qCritical()Marc Mutz2015-11-291-3/+3
|/ | | | | | | | | | | | | | | | | | | | | If, after checking a condition, we issue a qFatal() or a qCritical(), by definition that check is unlikely to be true. Tell the compiler so it can move the error handling code out of the normal code path to increase the effective icache size. Moved conditional code around where possible so that we could always use Q_UNLIKELY, instead of having to revert to Q_LIKELY here and there. In some cases, simplified the expressions newly wrapped in Q_UNLIKELY as a drive-by. Change-Id: I67537d62b04bc6977d69254690c5ebbdf98bfd6d Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add getter and setter for qt_qhash_seedGabriel de Dietrich2015-09-221-1/+49
| | | | | | | | | | | | | | | | | | In some cases it's not possible to use QT_HASH_SEED, specially when we need to set the environment variable from inside the application, as dynamically loaded libraries or plugins may create static QHash instances. That would set qt_qhash_seed to a value different from -1 and skip the env var value. For those cases, and when we still want to set qt_qhash_seed, we provide a way to enforce its value. Auto-tests accessing qt_qhash_seed directly have been updated accordingly. Usage in qdoc, uic and rcc has been left as is for the time being. Change-Id: I3b35b4fa0223c83b1348a6508641905a2a63266f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* doc: Add a few missing const keywords in \fn commandsMartin Smith2015-08-161-2/+2
| | | | | | | | | This adds "const" to a few \fn commands for new operators in QHash and QMap. Change-Id: I93cf7aaf88fcb4db17de5810b555b978e8119e20 Task-number: QTBUG-47669 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Introduce QHash key iteratorsSérgio Martins2015-07-281-1/+147
| | | | | | | | | | | So we can have interoperability with algorithms. Motivated by inefficient code like qDeleteAll(hash.keys()) [ChangeLog][QtCore][QHash] Added key iterators, accessible through keyBegin() and keyEnd(). Change-Id: I1f9db8a7a4294e1556cbb50b8fe5ebdcf0dc29a2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QtCore: assorted migrations to QString::asprintfMarc Mutz2015-02-121-3/+2
| | | | | Change-Id: Ie99d3eeeced89dd8336717954fd5ca7117bb20b4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* QHash: only fetch qt_qhash_seed when detaching from a null QHashMarc Mutz2015-01-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The old code fetched QHashData::seed from qt_qhash_seed on every detach. That is both unnecessary and wrong. It is uneccessary, because if the detached-from QHashData isn't shared_null, the seed has already been populated from qt_qhash_seed. It thus suffices to fetch the seed from qt_qhash_seed only when we detach from shared_null. It is wrong, because if qt_qhash_seed was changed between the detach from shared_null and a following detach, d->seed is now different from this->seed, but detach_helper simply clones the buckets 1:1 from this to d, leaving d in a corrupt state. By doing this change, we make QHash robust against on-the-fly changes to qt_qhash_seed (e.g. for testing, or added security). It also opens up the option to have API for changing the seed of a given QHash instance after it has been created (detach, set new seed, rehash). Change-Id: Ib251fc9a6204b42036e97a2fc66f644b379ab841 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: clean up class definitionMarc Mutz2015-01-101-10/+10
| | | | | | | ...by removing redundant '<Key, T>' and 'inline'. Change-Id: I9d81950c6384927633de07de511712f7274a1283 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Docs: e.g. -> for example in qhash.cppMarc Mutz2015-01-091-2/+2
| | | | | Change-Id: Ifee0117ddadfaa774fdd575467b03ca5b0baf433 Reviewed-by: Martin Smith <martin.smith@digia.com>
* Add qHashRange and qHashRangeCommutativeMarc Mutz2015-01-091-0/+85
| | | | | | | | | | | | | | | | | | | qHashRange() takes an (input iterator) range and hashes each element, combining the hash values using the hash combiner from Boost/N1837 with the magic number 0x9e3779b9, as described here: http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine qHashRangeCommutative() does the same but with a cummutative combiner (unsigned addition) to create hash values that are order-independent, e.g. for hashed containers. The obvious combiner, XOR, is a bad one because it eliminates duplicate elements. Signed addition cannot be used, since signed overflow leads to undefined behavior. [ChangeLog][QtCore] Added qHashRange() and qHashRangeCommutative() functions to aid implementing qHash() overloads for custom types. Change-Id: I3c2bbc9ce4bd0455262a70e0cf248486525e534f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>