tests: fix QCoreApplication parameters

The argument count (first parameter) is a reference, and thus must be
kept alive for the whole lifetime of the QCoreApplication instance,
as also the Qt apidocs say.

Also properly create a "string array" for the actual args, instead
of badly casting a string to that.

This fixes sporadic crashes in this test.
This commit is contained in:
Pino Toscano
2015-01-17 13:06:22 +01:00
parent a6bd96774a
commit afaf2ca73c
2 changed files with 5 additions and 3 deletions

View File

@@ -14,9 +14,9 @@ TestImport::TestImport()
// Init basic application
// The app needs to be initialized for the utf8 test
// to work
int argcount = 1;
const char* appname = "sqlb-unittests";
app = new QCoreApplication(argcount, const_cast<char**>(&appname));
argcount = 1;
args[0] = "sqlb-unittests";
app = new QCoreApplication(argcount, args);
}
TestImport::~TestImport()

View File

@@ -13,6 +13,8 @@ public:
~TestImport();
private:
int argcount;
char *args[1]; // the size must match what 'argcount' is set to
QCoreApplication* app;
private slots: