tst_QtBench: fix leak

Instead make "benchmarks" a member variable and call qDeleteAll() on it
in cleanupTestCase(). This doesn't make much difference since the
allocated resources would be freed when the whole test is destroyed
anyway, but still.

Change-Id: Iba66d32697fd3f2283185ee65a0a514176b4b258
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-08-17 01:08:51 +03:00
parent 0b3390f33d
commit 5941f192ab

View File

@ -107,9 +107,13 @@ class tst_QtBench : public QObject
{
Q_OBJECT
QList<Benchmark *> benchmarks;
private slots:
void qtBench();
void qtBench_data();
void cleanupTestCase() { qDeleteAll(benchmarks); }
};
QString makeString(int length)
@ -159,7 +163,6 @@ void tst_QtBench::qtBench_data()
"i erat, sed pellentesque\n"
"mi. Curabitur sed.";
QList<Benchmark *> benchmarks;
benchmarks << (new DrawText(shortString, DrawText::PainterMode));
benchmarks << (new DrawText(middleString, DrawText::PainterMode));
benchmarks << (new DrawText(longString, DrawText::PainterMode));