diff options
author | Tatu Lahtela <ext-tatu.lahtela@nokia.com> | 2010-11-11 14:22:24 +0200 |
---|---|---|
committer | Adrian Yanes <ext-adrian.yanes@nokia.com> | 2010-11-12 13:56:37 +0200 |
commit | 30fd863034284d28ddfcc4a7c6a57447a3f7bdb0 (patch) | |
tree | 6cf8455fcbab81af98a8dc2bf333dfb47b1139b5 | |
parent | 0fc7c4bc3f80cd80c081e0440419a33d21d336bc (diff) |
Fixes: NB#202799 - Application registration is broken (was: Topmost application detection does not work in 45-2 and qttas 0.9.2)
RevBy: Holger Schröder
Details: testability lib loading has to happen later, when the
application name is set correctly.
-rw-r--r-- | src/corelib/core/mcomponentdata.cpp | 93 | ||||
-rw-r--r-- | src/corelib/core/mcomponentdata_p.h | 7 |
2 files changed, 46 insertions, 54 deletions
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp index 032762e1..0a21763e 100644 --- a/src/corelib/core/mcomponentdata.cpp +++ b/src/corelib/core/mcomponentdata.cpp @@ -49,15 +49,10 @@ #include "mswiperecognizer.h" #include "msyslogclient.h" #include <MDebug> - -#ifdef TESTABLE -/// for testability plugin #include <QtPlugin> #include <QPluginLoader> #include <QLibraryInfo> #include "testabilityinterface.h" -// end testability -#endif #ifdef Q_WS_X11 #include <QX11Info> @@ -192,52 +187,21 @@ MComponentDataPrivate::MComponentDataPrivate() binaryName(), deviceName(), syslogServer(), - service(0) -#ifdef TESTABLE - , - testabilityInterface(0) -#endif - , + service(0), + testabilityInterface(0), q_ptr(NULL) { -#ifdef TESTABLE - // Activate testability plugin if exists - QString testabilityPluginPostfix = ".so"; - QString testabilityPlugin = "testability/libtestability"; - - testabilityPlugin = QLibraryInfo::location(QLibraryInfo::PluginsPath) + QDir::separator() + testabilityPlugin + testabilityPluginPostfix; - QPluginLoader loader(testabilityPlugin.toLatin1().data()); - - QObject *plugin = loader.instance(); - if (plugin) { - mDebug("MComponentData") << "Testability plugin loaded successfully!"; - testabilityInterface = qobject_cast<TestabilityInterface *>(plugin); - - if (testabilityInterface) { - mDebug("MComponentData") << "Testability interface obtained!"; - testabilityInterface->Initialize(); - } else { - mDebug("MComponentData") << "Failed to get testability interface!"; - } - } else { - mDebug("MComponentData") << QString("Testability plugin %1 load failed with error: %2") - .arg(testabilityPlugin).arg(loader.errorString()); - } -//end testability -#endif } MComponentDataPrivate::~MComponentDataPrivate() { -#ifdef TESTABLE //remove the testability plugin if it exists //makes sure that all resources used by the plugin //are free when the application exits if (testabilityInterface) { delete testabilityInterface; } -#endif delete theme; theme = 0; @@ -252,6 +216,32 @@ MComponentDataPrivate::~MComponentDataPrivate() deviceProfile = 0; } +void MComponentDataPrivate::testabilityInit() +{ + // Activate testability plugin if exists + QString testabilityPluginPostfix = ".so"; + QString testabilityPlugin = "testability/libtestability"; + + testabilityPlugin = QLibraryInfo::location(QLibraryInfo::PluginsPath) + QDir::separator() + testabilityPlugin + testabilityPluginPostfix; + QPluginLoader loader(testabilityPlugin.toLatin1().data()); + + QObject *plugin = loader.instance(); + if (plugin) { + mDebug("MComponentData") << "Testability plugin loaded successfully!"; + testabilityInterface = qobject_cast<TestabilityInterface *>(plugin); + + if (testabilityInterface) { + mDebug("MComponentData") << "Testability interface obtained!"; + testabilityInterface->Initialize(); + } else { + mDebug("MComponentData") << "Failed to get testability interface!"; + } + } else { + mDebug("MComponentData") << QString("Testability plugin %1 load failed with error: %2") + .arg(testabilityPlugin).arg(loader.errorString()); + } +} + void MComponentDataPrivate::debugInit(bool levelSet) { //Command line variables override environment variables @@ -287,6 +277,17 @@ void MComponentDataPrivate::debugInit(bool levelSet) } } } + + // If there was already a message handler, remove + // own message handler again. If our message handler + // was installed succesfully, initiate the connection to + // syslog, if syslogServer is not the empty string. + QtMsgHandler handler(qInstallMsgHandler(mMessageHandler)); + if (handler != 0) { + qInstallMsgHandler(handler); + } else if (!syslogServer.isEmpty()) { + initSyslogConnection(syslogServer); + } } MComponentData *MComponentData::instance() @@ -364,16 +365,10 @@ void MComponentDataPrivate::init(int &argc, char **argv, const QString &appIdent parseArguments(argc, argv, themeService); - // If there was already a message handler, remove - // own message handler again. If our message handler - // was installed succesfully, initiate the connection to - // syslog, if syslogServer is not the empty string. - QtMsgHandler handler(qInstallMsgHandler(mMessageHandler)); - if (handler != 0) { - qInstallMsgHandler(handler); - } else if (!syslogServer.isEmpty()) { - initSyslogConnection(syslogServer); - } +#ifdef TESTABLE + if (!MComponentCache::populating()) + testabilityInit(); +#endif //TESTABLE QFileInfo fileInfo(argv[0]); QString themeIdentifier = fileInfo.fileName(); @@ -764,6 +759,8 @@ void MComponentData::reinit(int &argc, char **argv, const QString &appIdentifier d->appName = fileInfo.fileName(); } + d->testabilityInit(); + MLocale systemLocale; systemLocale.installTrCatalog(d->appName); MLocale::setDefault(systemLocale); diff --git a/src/corelib/core/mcomponentdata_p.h b/src/corelib/core/mcomponentdata_p.h index ab6b48fb..8cc2045c 100644 --- a/src/corelib/core/mcomponentdata_p.h +++ b/src/corelib/core/mcomponentdata_p.h @@ -36,9 +36,7 @@ class MApplicationService; class MWindow; class MApplicationWindow; class MDeviceProfile; -#ifdef TESTABLE class TestabilityInterface; -#endif class MComponentDataPrivate { @@ -78,10 +76,7 @@ public: QString deviceName; QUrl syslogServer; MApplicationService *service; -#ifdef TESTABLE - // member to hold reference to the testability plugin in order to destroy plugin when the application is destructed TestabilityInterface *testabilityInterface; -#endif #ifdef Q_WS_X11 static QStack<MComponentData::ChainData> chainData; @@ -94,8 +89,8 @@ private: void registerDefaultService(const QString &appName); void registerNewService(MApplicationService *newService); void debugInit(bool levelSet); + void testabilityInit(); bool initSyslogConnection(const QUrl &url); }; - #endif |