summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp65
1 files changed, 53 insertions, 12 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index fd423d4479..df0ffce12d 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -264,6 +264,35 @@ struct QCoreApplicationData {
data->deref(); // deletes the data and the adopted thread
}
}
+
+#ifdef Q_OS_BLACKBERRY
+ //The QCoreApplicationData struct is only populated on demand, because it is rarely needed and would
+ //affect startup time
+ void loadManifest() {
+ static bool manifestLoadAttempt = false;
+ if (manifestLoadAttempt)
+ return;
+
+ manifestLoadAttempt = true;
+
+ QFile metafile(QStringLiteral("app/META-INF/MANIFEST.MF"));
+ if (!metafile.open(QIODevice::ReadOnly)) {
+ qWarning() << Q_FUNC_INFO << "Could not open application metafile for reading";
+ } else {
+ while (!metafile.atEnd() && (application.isEmpty() || applicationVersion.isEmpty() || orgName.isEmpty())) {
+ QByteArray line = metafile.readLine();
+ if (line.startsWith("Application-Name:"))
+ application = QString::fromUtf8(line.mid(18).trimmed());
+ else if (line.startsWith("Application-Version:"))
+ applicationVersion = QString::fromUtf8(line.mid(21).trimmed());
+ else if (line.startsWith("Package-Author:"))
+ orgName = QString::fromUtf8(line.mid(16).trimmed());
+ }
+ metafile.close();
+ }
+ }
+#endif
+
QString orgName, orgDomain, application;
QString applicationVersion;
@@ -363,16 +392,6 @@ void QCoreApplicationPrivate::createEventDispatcher()
#endif
}
-void QCoreApplicationPrivate::_q_initializeProcessManager()
-{
-#ifndef QT_NO_PROCESS
-# ifdef Q_OS_UNIX
- QProcessPrivate::initializeProcessManager();
-# endif
-#endif
-}
-
-
QThread *QCoreApplicationPrivate::theMainThread = 0;
QThread *QCoreApplicationPrivate::mainThread()
{
@@ -596,6 +615,12 @@ void QCoreApplication::init()
d->appendApplicationPathToLibraryPaths();
#endif
+#if defined(Q_OS_UNIX) && !(defined(QT_NO_PROCESS))
+ // Make sure the process manager thread object is created in the main
+ // thread.
+ QProcessPrivate::initializeProcessManager();
+#endif
+
#ifdef QT_EVAL
extern void qt_core_eval_init(uint);
qt_core_eval_init(d->application_type);
@@ -1765,6 +1790,15 @@ QString QCoreApplication::applicationFilePath()
#if defined(Q_OS_WIN)
d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath();
return d->cachedApplicationFilePath;
+#elif defined(Q_OS_BLACKBERRY)
+ QDir dir(QStringLiteral("./app/native/"));
+ QStringList executables = dir.entryList(QDir::Executable | QDir::Files);
+ if (!executables.empty()) {
+ //We assume that there is only one executable in the folder
+ return dir.absoluteFilePath(executables.first());
+ } else {
+ return QString();
+ }
#elif defined(Q_OS_MAC)
QString qAppFileName_str = qAppFileName();
if(!qAppFileName_str.isEmpty()) {
@@ -1930,6 +1964,9 @@ void QCoreApplication::setOrganizationName(const QString &orgName)
QString QCoreApplication::organizationName()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
return coreappdata()->orgName;
}
@@ -1977,6 +2014,9 @@ void QCoreApplication::setApplicationName(const QString &application)
QString QCoreApplication::applicationName()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
QString appname = coreappdata() ? coreappdata()->application : QString();
if (appname.isEmpty() && QCoreApplication::self)
appname = QCoreApplication::self->d_func()->appName();
@@ -2003,6 +2043,9 @@ void QCoreApplication::setApplicationVersion(const QString &version)
QString QCoreApplication::applicationVersion()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
return coreappdata()->applicationVersion;
}
@@ -2317,5 +2360,3 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
*/
QT_END_NAMESPACE
-
-#include "moc_qcoreapplication.cpp"