From ff561baabdf2f807ba4867e11f0dbed17ad4f8bf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Jul 2019 11:26:59 +0200 Subject: 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 Reviewed-by: Simon Hausmann --- src/testlib/qbenchmark.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/testlib') 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) -- cgit v1.2.3