Changes: Use QByteArray/QString in MDeclarativeCachePrivate::populate() instead of sprintf and C-arrays. Test argv in ut_dbooster.

pull/1/head
Jussi Lind 15 years ago
parent 7fdae4cdbf
commit 8b3322ddc4

@ -53,17 +53,17 @@ void MDeclarativeCachePrivate::populate()
cachePopulated = true;
static const char *const emptyString = "";
static const char *const appNameFormat = "mdeclarativecache_pre_initialized_qapplication%d";
static char appName[strlen(appNameFormat) + 8];
static const QString appNameFormat = "mdeclarativecache_pre_initialized_qapplication-%1";
static QByteArray appName;
// Append pid to appName to make it unique. This is required because the
// libminputcontext.so instantiates MComponentData, which in turn registers
// a dbus service with the application's name.
sprintf(appName, appNameFormat, getpid());
appName = appNameFormat.arg(getpid()).toLatin1();
// We support at most ARGV_LIMIT arguments in QCoreApplication. These will be set when real
// arguments are known (in MDeclarativeCachePrivate::qApplication).
initialArgv[0] = const_cast<char *>(appName);
initialArgv[0] = const_cast<char *>(appName.constData());
for (int i = 1; i < initialArgc; i++) {
initialArgv[i] = const_cast<char *>(emptyString);
}

@ -71,8 +71,7 @@ public:
*/
static QString applicationFilePath();
protected:
protected:
static MDeclarativeCachePrivate* const d_ptr;
@ -84,7 +83,6 @@ private:
//! Disable assignment operator
MDeclarativeCache & operator= (const MDeclarativeCache & r);
#ifdef UNIT_TEST
friend class Ut_MDeclarativeCache;
#endif

@ -53,7 +53,15 @@ void Ut_DBooster::testPreload()
const char * argv[] = {"foo"};
int argc = 1;
QVERIFY(MDeclarativeCache::qApplication(argc, const_cast<char **>(argv)));
// TODO: Somehow make sure that MDeclarativeCache really returns the cached
// QApplication instead of creating a new one here.
QApplication * app = MDeclarativeCache::qApplication(argc, const_cast<char **>(argv));
QVERIFY(app);
QStringList args = app->arguments();
QVERIFY(args.length() == 1);
QVERIFY(args[0] == "foo");
QVERIFY(MDeclarativeCache::qDeclarativeView());
}

Loading…
Cancel
Save