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>
bb10
Ulf Hermann 2019-07-04 11:26:59 +02:00
parent 656117100b
commit ff561baabd
1 changed files with 2 additions and 1 deletions

View File

@ -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)