diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-18 17:40:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-18 18:18:40 (GMT) |
commit | 981e6442b98a2377a60dd56c23491de922080ef7 (patch) | |
tree | ac0ac646e0bdb970022c96aa74c3ef473d640c14 /src/testlib/qtestcase.cpp | |
parent | 3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290 (diff) | |
download | Qt-981e6442b98a2377a60dd56c23491de922080ef7.zip Qt-981e6442b98a2377a60dd56c23491de922080ef7.tar.gz Qt-981e6442b98a2377a60dd56c23491de922080ef7.tar.bz2 |
Remove a global static in QtTest: we can do the same with dynamic
allocation.
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index a144923..15c49e1 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -808,12 +808,12 @@ namespace QTest { static QObject *currentTestObject = 0; - struct TestFunction { + static struct TestFunction { TestFunction():function(0), data(0) {} ~TestFunction() { delete [] data; } int function; char *data; - } testFuncs[512]; + } *testFuncs; /** * Contains the count of test functions that was supplied @@ -1120,6 +1120,11 @@ static void qParseArgs(int argc, char *argv[]) exit(1); } ++QTest::lastTestFuncIdx; + if (!QTest::testFuncs) { + struct Cleanup { ~Cleanup() { delete[] QTest::testFuncs; } }; + static Cleanup cleanup; + QTest::testFuncs = new TestFunction[512]; + } QTest::testFuncs[QTest::lastTestFuncIdx].function = idx; QTest::testFuncs[QTest::lastTestFuncIdx].data = data; QTEST_ASSERT(QTest::lastTestFuncIdx < 512); |