summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qset
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-09-21 15:53:49 +0200
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-09-22 14:17:46 +0000
commita14fadfb640103ecea76c3966cf23668bb7f448b (patch)
treea8a9de3fca0070109066085e3c467ec21534129f /tests/auto/corelib/tools/qset
parent863dfb1541f4f0865a6e4ee42dbef159eaa7f2d0 (diff)
Add getter and setter for qt_qhash_seed
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>
Diffstat (limited to 'tests/auto/corelib/tools/qset')
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index ef0ebabd66..134d257d64 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -970,24 +970,6 @@ void tst_QSet::initializerList()
#endif
}
-QT_BEGIN_NAMESPACE
-extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed; // from qhash.cpp
-QT_END_NAMESPACE
-
-class QtQHashSeedSaver {
- int oldSeed, newSeed;
-public:
- explicit QtQHashSeedSaver(int seed)
- : oldSeed(qt_qhash_seed.fetchAndStoreRelaxed(seed)),
- newSeed(seed)
- {}
- ~QtQHashSeedSaver()
- {
- // only restore when no-one else changed the seed in the meantime:
- qt_qhash_seed.testAndSetRelaxed(newSeed, oldSeed);
- }
-};
-
void tst_QSet::qhash()
{
//
@@ -995,14 +977,14 @@ void tst_QSet::qhash()
//
{
// create some deterministic initial state:
- const QtQHashSeedSaver seed1(0);
+ qSetGlobalQHashSeed(0);
QSet<int> s1;
s1.reserve(4);
s1 << 400 << 300 << 200 << 100;
// also change the seed:
- const QtQHashSeedSaver seed2(0x10101010);
+ qSetGlobalQHashSeed(0x10101010);
QSet<int> s2;
s2.reserve(100); // provoke different bucket counts
@@ -1049,7 +1031,7 @@ void tst_QSet::intersects()
s1 << 200;
QVERIFY(s1.intersects(s2));
- const QtQHashSeedSaver seedSaver(0x10101010);
+ qSetGlobalQHashSeed(0x10101010);
QSet<int> s3;
s3 << 500;
QVERIFY(!s1.intersects(s3));