summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-07-04 11:26:59 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-07-04 15:39:09 +0200
commitff561baabdf2f807ba4867e11f0dbed17ad4f8bf (patch)
tree3ba8b18ff87a41d165060750350c0be6a66964d5 /src/testlib
parent656117100b52bb404828d02106fd0dee760b6019 (diff)
Testlib: Reset the global benchmark data only if it matches
You can create multiple instances of QBenchmarkGlobalData as the ctor is public. The qmltest plugin does create a static one, but only conditionally assigns it to the singleton pointer. On shutdown the plugin is removed and the QBenchmarkGlobalData::current should only be reset by the dtor if it's actually pointing to the same object. Change-Id: I616c1ccf6f7a00abf1de342094da88481510bc7b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qbenchmark.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp
index 8d5543a0fc..cbc009c993 100644
--- a/src/testlib/qbenchmark.cpp
+++ b/src/testlib/qbenchmark.cpp
@@ -66,7 +66,8 @@ QBenchmarkGlobalData::QBenchmarkGlobalData()
QBenchmarkGlobalData::~QBenchmarkGlobalData()
{
delete measurer;
- QBenchmarkGlobalData::current = 0;
+ if (QBenchmarkGlobalData::current == this)
+ QBenchmarkGlobalData::current = nullptr;
}
void QBenchmarkGlobalData::setMode(Mode mode)