diff options
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 106 |
1 files changed, 13 insertions, 93 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index abc5af94cb..8d9b923e61 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -66,19 +66,14 @@ #ifndef QT_NO_QOBJECT #if defined(Q_OS_UNIX) -# if defined(Q_OS_BLACKBERRY) -# include "qeventdispatcher_blackberry_p.h" -# include <process.h> -# include <unistd.h> -# elif defined(Q_OS_OSX) -# include "qeventdispatcher_cf_p.h" -# include "qeventdispatcher_unix_p.h" -# else -# if !defined(QT_NO_GLIB) -# include "qeventdispatcher_glib_p.h" -# endif -# include "qeventdispatcher_unix_p.h" +# if defined(Q_OS_OSX) +# include "qeventdispatcher_cf_p.h" +# else +# if !defined(QT_NO_GLIB) +# include "qeventdispatcher_glib_p.h" # endif +# endif +# include "qeventdispatcher_unix_p.h" #endif #ifdef Q_OS_WIN # ifdef Q_OS_WINRT @@ -338,34 +333,6 @@ struct QCoreApplicationData { #endif } -#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("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; QString application; // application name, initially from argv[0], can then be modified. QString applicationVersion; @@ -450,7 +417,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint QCoreApplicationPrivate::is_app_closing = false; # if defined(Q_OS_UNIX) - if (!setuidAllowed && (geteuid() != getuid())) + if (Q_UNLIKELY(!setuidAllowed && (geteuid() != getuid()))) qFatal("FATAL: The application binary appears to be running setuid, this is a security hole."); # endif // Q_OS_UNIX @@ -506,9 +473,7 @@ void QCoreApplicationPrivate::createEventDispatcher() { Q_Q(QCoreApplication); #if defined(Q_OS_UNIX) -# if defined(Q_OS_BLACKBERRY) - eventDispatcher = new QEventDispatcherBlackberry(q); -# elif defined(Q_OS_OSX) +# if defined(Q_OS_OSX) bool ok = false; int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok); if (ok && value > 0) @@ -600,7 +565,7 @@ void QCoreApplicationPrivate::initLocale() if (qt_locale_initialized) return; qt_locale_initialized = true; -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(QT_BOOTSTRAPPED) setlocale(LC_ALL, ""); #endif } @@ -2135,33 +2100,6 @@ QString QCoreApplication::applicationFilePath() #if defined(Q_OS_WIN) QCoreApplicationPrivate::setApplicationFilePath(QFileInfo(qAppFileName()).filePath()); return *QCoreApplicationPrivate::cachedApplicationFilePath; -#elif defined(Q_OS_BLACKBERRY) - if (!arguments().isEmpty()) { // args is never empty, but the navigator can change behaviour some day - QFileInfo fileInfo(arguments().at(0)); - const bool zygotized = fileInfo.exists(); - if (zygotized) { - // Handle the zygotized case: - QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(fileInfo.absoluteFilePath())); - return *QCoreApplicationPrivate::cachedApplicationFilePath; - } - } - - // Handle the non-zygotized case: - const size_t maximum_path = static_cast<size_t>(pathconf("/",_PC_PATH_MAX)); - char buff[maximum_path+1]; - if (_cmdname(buff)) { - QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(QString::fromLocal8Bit(buff))); - } else { - qWarning("QCoreApplication::applicationFilePath: _cmdname() failed"); - // _cmdname() won't fail, but just in case, fallback to the old method - 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 - QCoreApplicationPrivate::setApplicationFilePath(dir.absoluteFilePath(executables.first())); - } - } - return *QCoreApplicationPrivate::cachedApplicationFilePath; #elif defined(Q_OS_MAC) QString qAppFileName_str = qAppFileName(); if(!qAppFileName_str.isEmpty()) { @@ -2327,9 +2265,6 @@ QStringList QCoreApplication::arguments() organizationName(). On all other platforms, QSettings uses organizationName() as the organization. - On BlackBerry this property is read-only. It is obtained from the - BAR application descriptor file. - \sa organizationDomain, applicationName */ @@ -2354,9 +2289,6 @@ void QCoreApplication::setOrganizationName(const QString &orgName) QString QCoreApplication::organizationName() { -#ifdef Q_OS_BLACKBERRY - coreappdata()->loadManifest(); -#endif return coreappdata()->orgName; } @@ -2407,9 +2339,6 @@ QString QCoreApplication::organizationDomain() If not set, the application name defaults to the executable name (since 5.0). - On BlackBerry this property is read-only. It is obtained from the - BAR application descriptor file. - \sa organizationName, organizationDomain, applicationVersion, applicationFilePath() */ /*! @@ -2435,9 +2364,6 @@ void QCoreApplication::setApplicationName(const QString &application) QString QCoreApplication::applicationName() { -#ifdef Q_OS_BLACKBERRY - coreappdata()->loadManifest(); -#endif return coreappdata() ? coreappdata()->application : QString(); } @@ -2452,9 +2378,6 @@ Q_CORE_EXPORT QString qt_applicationName_noFallback() \since 4.4 \brief the version of this application - On BlackBerry this property is read-only. It is obtained from the - BAR application descriptor file. - \sa applicationName, organizationName, organizationDomain */ /*! @@ -2476,9 +2399,6 @@ void QCoreApplication::setApplicationVersion(const QString &version) QString QCoreApplication::applicationVersion() { -#ifdef Q_OS_BLACKBERRY - coreappdata()->loadManifest(); -#endif return coreappdata()->applicationVersion; } @@ -2698,7 +2618,7 @@ void QCoreApplication::removeLibraryPath(const QString &path) i.e. MSG or XCB event structs. \note Native event filters will be disabled in the application when the - Qt::AA_MacPluginApplication attribute is set. + Qt::AA_PluginApplication attribute is set. For maximum portability, you should always try to use QEvent and QObject::installEventFilter() whenever possible. @@ -2709,8 +2629,8 @@ void QCoreApplication::removeLibraryPath(const QString &path) */ void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj) { - if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { - qWarning("Native event filters are not applied when the Qt::AA_MacPluginApplication attribute is set"); + if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { + qWarning("Native event filters are not applied when the Qt::AA_PluginApplication attribute is set"); return; } |