diff options
Diffstat (limited to 'src/corelib')
41 files changed, 374 insertions, 143 deletions
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 31a06541ed..3fd07e0813 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -171,8 +171,8 @@ bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa template<> template <typename T> inline bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW { - register T tempValue; - register int result; + T tempValue; + int result; asm volatile("0:\n" "ldrex %[tempValue], [%[_q_value]]\n" "eors %[result], %[tempValue], %[expectedValue]\n" @@ -352,8 +352,8 @@ bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa template<> template <typename T> inline bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW { - register T tempValue; - register T result; + T tempValue; + T result; asm volatile("0:\n" "ldrexb %[tempValue], [%[_q_value]]\n" "eors %[result], %[tempValue], %[expectedValue]\n" @@ -474,8 +474,8 @@ bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa template<> template <typename T> inline bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW { - register T tempValue; - register T result; + T tempValue; + T result; asm volatile("0:\n" "ldrexh %[tempValue], [%[_q_value]]\n" "eors %[result], %[tempValue], %[expectedValue]\n" @@ -608,8 +608,8 @@ bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa template<> template <typename T> inline bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW { - register T tempValue; - register T result; + T tempValue; + T result; asm volatile("0:\n" "ldrexd %[tempValue], %H[tempValue], [%[_q_value]]\n" "eor %[result], %[tempValue], %[expectedValue]\n" diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 18fdfb18f3..2ad24d33b1 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -37,7 +37,8 @@ exampledirs += \ snippets \ ../../../examples/threads/ \ ../../../examples/tools/ \ - ../../../examples/json/ + ../../../examples/json/ \ + ../../../examples/network/dnslookup imagedirs += images diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp index fde37bb549..5c6055defe 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp @@ -47,7 +47,7 @@ class WorkerThread : public QThread Q_OBJECT void run() Q_DECL_OVERRIDE { QString result; - /* expensive or blocking operation */ + /* ... here is the expensive or blocking operation ... */ emit resultReady(result); } signals: @@ -71,7 +71,8 @@ class Worker : public QObject public slots: void doWork(const QString ¶meter) { - // ... + QString result; + /* ... here is the expensive or blocking operation ... */ emit resultReady(result); } @@ -87,7 +88,7 @@ public: Controller() { Worker *worker = new Worker; worker->moveToThread(&workerThread); - connect(workerThread, &QThread::finished, worker, &QObject::deleteLater); + connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); connect(this, &Controller::operate, worker, &Worker::doWork); connect(worker, &Worker::resultReady, this, &Controller::handleResults); workerThread.start(); diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c15305322b..66664f0f2a 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3258,7 +3258,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) On Blackberry the message is sent to slogger2. This function does nothing if \c QT_NO_WARNING_OUTPUT was defined during compilation; it exits if the environment variable \c - QT_FATAL_WARNINGS is defined. + QT_FATAL_WARNINGS is not empty. This function takes a format string and a list of arguments, similar to the C printf() function. The format should be a Latin-1 @@ -3291,6 +3291,8 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) stderr. Under Windows, the message is sent to the debugger. On Blackberry the message is sent to slogger2. + It exits if the environment variable QT_FATAL_CRITICALS is not empty. + This function takes a format string and a list of arguments, similar to the C printf() function. The format should be a Latin-1 string. diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7789461a1c..cd422dfd87 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -534,8 +534,8 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max #ifdef Q_OS_DARWIN # define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \ - ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \ - (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios)) + ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios)) # define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) \ ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \ @@ -896,8 +896,11 @@ struct QForeachContainerBase {}; template <typename T> class QForeachContainer : public QForeachContainerBase { + QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE; public: inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){} + QForeachContainer(const QForeachContainer &other) + : c(other.c), brk(other.brk), i(other.i), e(other.e) {} const T c; mutable int brk; mutable typename T::const_iterator i, e; diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 689de48e26..39bfd339c3 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -257,9 +257,9 @@ QLibraryInfo::buildDate() #if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too # ifdef __apple_build_version__ // Apple clang has other version numbers -# define COMPILER_STRING __clang_version__ " (Apple)" +# define COMPILER_STRING "Clang " __clang_version__ " (Apple)" # else -# define COMPILER_STRING __clang_version__ +# define COMPILER_STRING "Clang " __clang_version__ # endif #elif defined(Q_CC_GNU) # define COMPILER_STRING "GCC " __VERSION__ diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 64dd544cf0..8c1d8b867d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -83,6 +83,11 @@ static bool isFatal(QtMsgType msgType) if (msgType == QtFatalMsg) return true; + if (msgType == QtCriticalMsg) { + static bool fatalCriticals = !qEnvironmentVariableIsEmpty("QT_FATAL_CRITICALS"); + return fatalCriticals; + } + if (msgType == QtWarningMsg || msgType == QtCriticalMsg) { static bool fatalWarnings = !qEnvironmentVariableIsEmpty("QT_FATAL_WARNINGS"); return fatalWarnings; @@ -1220,7 +1225,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con logMessage.chop(1); systemd_default_message_handler(type, context, logMessage); } else { - fprintf(stderr, "%s", logMessage.toUtf8().constData()); + fprintf(stderr, "%s", logMessage.toLocal8Bit().constData()); fflush(stderr); } #elif defined(Q_OS_ANDROID) @@ -1479,12 +1484,15 @@ void qErrnoWarning(int code, const char *msg, ...) \c %{if-warning}, \c %{if-critical} or \c %{if-fatal} followed by an \c %{endif}. What is inside the \c %{if-*} and \c %{endif} will only be printed if the type matches. + Finally, text inside \c %{if-category} ... \c %{endif} is only printed if the category + is not the default one. + Example: \code QT_MESSAGE_PATTERN="[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" \endcode - The default \a pattern is "%{message}". + The default \a pattern is "%{if-category}%{category}: %{endif}%{message}". The \a pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN environment variable; if both qSetMessagePattern() is called and QT_MESSAGE_PATTERN is diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index d7ae97e911..839d352d36 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -267,6 +267,8 @@ public: TextJustificationForced = 0x10000, TextForceLeftToRight = 0x20000, TextForceRightToLeft = 0x40000, + // Ensures that the longest variant is always used when computing the + // size of a multi-variant string. TextLongestVariant = 0x80000, TextBypassShaping = 0x100000 }; diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 31bc18749b..8ade3f86d6 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -493,8 +493,7 @@ text; otherwise this width is excluded. \value TextJustificationForced Ensures that text lines are justified. - \omitvalue TextLongestVariant Ensures that the longest variant is always used - when computing the size of a multi-variant string. (Internal) + \omitvalue TextLongestVariant \omitvalue TextBypassShaping \omitvalue TextForceLeftToRight \omitvalue TextForceRightToLeft diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 989e4644c7..f651860e08 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -148,7 +148,7 @@ win32 { } } else:blackberry { SOURCES += io/qstandardpaths_blackberry.cpp - } else:android { + } else:android:!android-no-sdk { SOURCES += io/qstandardpaths_android.cpp } else { SOURCES += io/qstandardpaths_unix.cpp diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index ea3a3ca13d..6c0f31fb55 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>> ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -89,35 +89,23 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e QFileInfo info(entry.filePath()); QString suffix = info.suffix(); - // First step: is the extenstion known ? - if (suffix == QLatin1String("app") - || suffix == QLatin1String("debug") - || suffix == QLatin1String("profile") - || suffix == QLatin1String("bundle") - || suffix == QLatin1String("pkg")) { - return true; - } - - // Second step: check if an application knows the package type - const QByteArray &native = entry.nativeFilePath(); - const char *nativeFilePath = native.constData(); - int nativeFilePathLength = native.size(); - - QCFType<CFStringRef> path = CFStringCreateWithBytes(0, - reinterpret_cast<const UInt8*>(nativeFilePath), - nativeFilePathLength, - kCFStringEncodingUTF8, - false); - - QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); - - UInt32 type, creator; - // Well created packages have the PkgInfo file - if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) - return true; - - // Find if an application other than Finder claims to know how to handle the package if (suffix.length() > 0) { + // First step: is the extension known ? + CFStringRef extensionRef = QCFString::toCFStringRef(suffix); + CFStringRef uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL); + if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle)) + return true; + + // Second step: check if an application knows the package type + CFStringRef path = QCFString::toCFStringRef(entry.filePath()); + QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); + + UInt32 type, creator; + // Well created packages have the PkgInfo file + if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) + return true; + + // Find if an application other than Finder claims to know how to handle the package QCFType<CFURLRef> application; LSGetApplicationForURL(url, kLSRolesEditor|kLSRolesViewer|kLSRolesViewer, @@ -134,7 +122,7 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e // Third step: check if the directory has the package bit set FSRef packageRef; - FSPathMakeRef((UInt8 *)nativeFilePath, &packageRef, NULL); + FSPathMakeRef((UInt8 *)entry.nativeFilePath().constData(), &packageRef, NULL); FSCatalogInfo catalogInfo; FSGetCatalogInfo(&packageRef, diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index dbc6d28846..7741eb4c1e 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -74,6 +74,8 @@ # define SECURITY_WIN32 # include <security.h> #else // !Q_OS_WINRT +# include "qstandardpaths.h" +# include "qthreadstorage.h" # include <wrl.h> # include <windows.foundation.h> # include <windows.storage.h> @@ -1151,6 +1153,18 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea bool existed = false; if (isDirPath(chunk, &existed) && existed) continue; +#ifdef Q_OS_WINRT + static QThreadStorage<QString> dataLocation; + if (!dataLocation.hasLocalData()) + dataLocation.setLocalData(QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation))); + static QThreadStorage<QString> tempLocation; + if (!tempLocation.hasLocalData()) + tempLocation.setLocalData(QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::TempLocation))); + // We try to create something outside the sandbox, which is forbidden + // However we could still try to pass into the sandbox + if (dataLocation.localData().startsWith(chunk) || tempLocation.localData().startsWith(chunk)) + continue; +#endif } return false; } diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 5fd20c6d74..3031c7a27e 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -138,6 +138,11 @@ # define __NR_inotify_add_watch 285 # define __NR_inotify_rm_watch 286 # define __NR_inotify_init1 328 +#elif defined (__aarch64__) +# define __NR_inotify_init1 26 +# define __NR_inotify_add_watch 27 +# define __NR_inotify_rm_watch 28 +// no inotify_init for aarch64 #else # error "This architecture is not supported. Please see http://www.qt-project.org/" #endif @@ -155,7 +160,11 @@ static inline int syscall(...) { return -1; } static inline int inotify_init() { +#ifdef __NR_inotify_init return syscall(__NR_inotify_init); +#else + return syscall(__NR_inotify_init1, 0); +#endif } static inline int inotify_add_watch(int fd, const char *name, __u32 mask) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 23f1ffbd16..7e6883fd14 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -62,7 +62,6 @@ Q_GLOBAL_STATIC(QLoggingRegistry, qtLoggingRegistry) Constructs a logging rule with default values. */ QLoggingRule::QLoggingRule() : - flags(Invalid), enabled(false) { } @@ -73,7 +72,6 @@ QLoggingRule::QLoggingRule() : */ QLoggingRule::QLoggingRule(const QStringRef &pattern, bool enabled) : messageType(-1), - flags(Invalid), enabled(enabled) { parse(pattern); @@ -147,7 +145,6 @@ void QLoggingRule::parse(const QStringRef &pattern) p = pattern; } - flags = Invalid; if (!p.contains(QLatin1Char('*'))) { flags = FullText; } else { @@ -160,7 +157,7 @@ void QLoggingRule::parse(const QStringRef &pattern) p = QStringRef(p.string(), p.position() + 1, p.length() - 1); } if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end - flags = Invalid; + flags = 0; } category = p.toString(); @@ -224,7 +221,11 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) const QStringRef value = line.midRef(equalPos + 1); bool enabled = (value.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0); - _rules.append(QLoggingRule(pattern, enabled)); + QLoggingRule rule(pattern, enabled); + if (rule.flags != 0) + _rules.append(rule); + else + warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); } } } diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 21896bb268..48804cfc2b 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -72,7 +72,6 @@ public: int pass(const QString &categoryName, QtMsgType type) const; enum PatternFlag { - Invalid = 0x0, FullText = 0x1, LeftFilter = 0x2, RightFilter = 0x4, diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 3b78351809..18391703da 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -165,7 +165,7 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list QStringList::ConstIterator it = list.constBegin(), end = list.constEnd(); for ( ; it != end; ++it) { - int pos = it->indexOf(QLatin1Char('=')); + int pos = it->indexOf(QLatin1Char('='), 1); if (pos < 1) continue; @@ -2227,6 +2227,8 @@ void QProcess::start(const QString &command, OpenMode mode) } /*! + \since 5.0 + Returns the program the process was last started with. \sa start() @@ -2256,6 +2258,8 @@ void QProcess::setProgram(const QString &program) } /*! + \since 5.0 + Returns the command line arguments the process was last started with. \sa start() diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 219bdf8200..5d65b2a068 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -390,6 +390,11 @@ public: qint64 writeToStdin(const char *data, qint64 maxlen); void cleanup(); + +#ifdef Q_OS_BLACKBERRY + QList<QSocketNotifier *> defaultNotifiers() const; +#endif // Q_OS_BLACKBERRY + #ifdef Q_OS_UNIX static void initializeProcessManager(); #endif diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 0e917ef438..8674371baa 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1042,17 +1042,6 @@ void QProcessPrivate::killProcess() ::kill(pid_t(pid), SIGKILL); } -static int select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) -{ - if (timeout < 0) - return qt_safe_select(nfds, fdread, fdwrite, 0, 0); - - struct timespec tv; - tv.tv_sec = timeout / 1000; - tv.tv_nsec = (timeout % 1000) * 1000 * 1000; - return qt_safe_select(nfds, fdread, fdwrite, 0, &tv); -} - /* Returns the difference between msecs and elapsed. If msecs is -1, however, -1 is returned. @@ -1066,41 +1055,6 @@ static int qt_timeout_value(int msecs, int elapsed) return timeout < 0 ? 0 : timeout; } -#ifdef Q_OS_BLACKBERRY -// The BlackBerry event dispatcher uses bps_get_event. Unfortunately, already registered -// socket notifiers are disabled by a call to select. This is to rearm the standard streams. -static int bb_select(QProcessPrivate *process, int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) -{ - bool stdoutEnabled = false; - bool stderrEnabled = false; - bool stdinEnabled = false; - - if (process->stdoutChannel.notifier && process->stdoutChannel.notifier->isEnabled()) { - stdoutEnabled = true; - process->stdoutChannel.notifier->setEnabled(false); - } - if (process->stderrChannel.notifier && process->stderrChannel.notifier->isEnabled()) { - stderrEnabled = true; - process->stderrChannel.notifier->setEnabled(false); - } - if (process->stdinChannel.notifier && process->stdinChannel.notifier->isEnabled()) { - stdinEnabled = true; - process->stdinChannel.notifier->setEnabled(false); - } - - const int ret = select_msecs(nfds, fdread, fdwrite, timeout); - - if (stdoutEnabled) - process->stdoutChannel.notifier->setEnabled(true); - if (stderrEnabled) - process->stderrChannel.notifier->setEnabled(true); - if (stdinEnabled) - process->stdinChannel.notifier->setEnabled(true); - - return ret; -} -#endif // Q_OS_BLACKBERRY - bool QProcessPrivate::waitForStarted(int msecs) { Q_Q(QProcess); @@ -1113,7 +1067,7 @@ bool QProcessPrivate::waitForStarted(int msecs) fd_set fds; FD_ZERO(&fds); FD_SET(childStartedPipe[0], &fds); - if (select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0) { + if (qt_select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0) { processError = QProcess::Timedout; q->setErrorString(QProcess::tr("Process operation timed out")); #if defined (QPROCESS_DEBUG) @@ -1129,6 +1083,17 @@ bool QProcessPrivate::waitForStarted(int msecs) return startedEmitted; } +#ifdef Q_OS_BLACKBERRY +QList<QSocketNotifier *> QProcessPrivate::defaultNotifiers() const +{ + QList<QSocketNotifier *> notifiers; + notifiers << stdoutChannel.notifier + << stderrChannel.notifier + << stdinChannel.notifier; + return notifiers; +} +#endif // Q_OS_BLACKBERRY + bool QProcessPrivate::waitForReadyRead(int msecs) { Q_Q(QProcess); @@ -1139,6 +1104,10 @@ bool QProcessPrivate::waitForReadyRead(int msecs) QElapsedTimer stopWatch; stopWatch.start(); +#ifdef Q_OS_BLACKBERRY + QList<QSocketNotifier *> notifiers = defaultNotifiers(); +#endif + forever { fd_set fdread; fd_set fdwrite; @@ -1162,9 +1131,9 @@ bool QProcessPrivate::waitForReadyRead(int msecs) int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY - int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); + int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else - int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); + int ret = qt_select_msecs(nfds + 1, &fdread, &fdwrite, timeout); #endif if (ret < 0) { break; @@ -1215,6 +1184,10 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) QElapsedTimer stopWatch; stopWatch.start(); +#ifdef Q_OS_BLACKBERRY + QList<QSocketNotifier *> notifiers = defaultNotifiers(); +#endif + while (!writeBuffer.isEmpty()) { fd_set fdread; fd_set fdwrite; @@ -1239,9 +1212,9 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY - int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); + int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else - int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); + int ret = qt_select_msecs(nfds + 1, &fdread, &fdwrite, timeout); #endif if (ret < 0) { break; @@ -1286,6 +1259,10 @@ bool QProcessPrivate::waitForFinished(int msecs) QElapsedTimer stopWatch; stopWatch.start(); +#ifdef Q_OS_BLACKBERRY + QList<QSocketNotifier *> notifiers = defaultNotifiers(); +#endif + forever { fd_set fdread; fd_set fdwrite; @@ -1310,9 +1287,9 @@ bool QProcessPrivate::waitForFinished(int msecs) int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY - int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); + int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else - int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); + int ret = qt_select_msecs(nfds + 1, &fdread, &fdwrite, timeout); #endif if (ret < 0) { break; @@ -1349,7 +1326,7 @@ bool QProcessPrivate::waitForWrite(int msecs) fd_set fdwrite; FD_ZERO(&fdwrite); FD_SET(stdinChannel.pipe[1], &fdwrite); - return select_msecs(stdinChannel.pipe[1] + 1, 0, &fdwrite, msecs < 0 ? 0 : msecs) == 1; + return qt_select_msecs(stdinChannel.pipe[1] + 1, 0, &fdwrite, msecs < 0 ? 0 : msecs) == 1; } void QProcessPrivate::findExitCode() diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index a3727a6a4b..0406aeb501 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2369,6 +2369,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, stored in the following registry path: \c{HKEY_LOCAL_MACHINE\Software\WOW6432node}. + On BlackBerry only a single file is used (see \l{Platform Limitations}). + If the file format is NativeFormat, this is "Settings/MySoft/Star Runner.conf" + in the application's home directory. + If the file format is IniFormat, the following files are used on Unix and Mac OS X: @@ -2393,8 +2397,12 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, %COMMON_APPDATA% path is usually \tt{C:\\Documents and Settings\\All Users\\Application Data}. + On BlackBerry only a single file is used (see \l{Platform Limitations}). + If the file format is IniFormat, this is "Settings/MySoft/Star Runner.ini" + in the application's home directory. + The paths for the \c .ini and \c .conf files can be changed using - setPath(). On Unix and Mac OS X, the user can override them by by + setPath(). On Unix and Mac OS X, the user can override them by setting the \c XDG_CONFIG_HOME environment variable; see setPath() for details. @@ -2498,7 +2506,8 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, allowed to read or write outside of this sandbox. This involves the following limitations: \list - \li As there is only a single scope the scope is simply ignored. + \li As there is only a single scope the scope is simply ignored, + i.e. there is no difference between SystemScope and UserScope. \li The \l{Fallback Mechanism} is not applied, i.e. only a single location is considered. \li It is advised against setting and using custom file paths. diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp index 9b6a088a30..bd72de11bb 100644 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ b/src/corelib/io/qstandardpaths_winrt.cpp @@ -74,6 +74,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) switch (type) { case ConfigLocation: // same as DataLocation, on Windows + case GenericConfigLocation: // same as GenericDataLocation, on Windows case DataLocation: case GenericDataLocation: { ComPtr<IApplicationDataStatics> applicationDataStatics; diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index e4181b5c86..568453ec07 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -58,6 +58,10 @@ #include <mach/mach_time.h> #endif +#ifdef Q_OS_BLACKBERRY +#include <qsocketnotifier.h> +#endif // Q_OS_BLACKBERRY + QT_BEGIN_NAMESPACE static inline bool time_update(struct timespec *tv, const struct timespec &start, @@ -106,4 +110,43 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, } } +int qt_select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) +{ + if (timeout < 0) + return qt_safe_select(nfds, fdread, fdwrite, 0, 0); + + struct timespec tv; + tv.tv_sec = timeout / 1000; + tv.tv_nsec = (timeout % 1000) * 1000 * 1000; + return qt_safe_select(nfds, fdread, fdwrite, 0, &tv); +} + +#ifdef Q_OS_BLACKBERRY +// The BlackBerry event dispatcher uses bps_get_event. Unfortunately, already registered +// socket notifiers are disabled by a call to select. This is to rearm the standard streams. +int bb_select(QList<QSocketNotifier *> socketNotifiers, int nfds, fd_set *fdread, fd_set *fdwrite, + int timeout) +{ + QList<bool> socketNotifiersEnabled; + socketNotifiersEnabled.reserve(socketNotifiers.count()); + for (int a = 0; a < socketNotifiers.count(); ++a) { + if (socketNotifiers.at(a) && socketNotifiers.at(a)->isEnabled()) { + socketNotifiersEnabled.append(true); + socketNotifiers.at(a)->setEnabled(false); + } else { + socketNotifiersEnabled.append(false); + } + } + + const int ret = qt_select_msecs(nfds, fdread, fdwrite, timeout); + + for (int a = 0; a < socketNotifiers.count(); ++a) { + if (socketNotifiersEnabled.at(a) == true) + socketNotifiers.at(a)->setEnabled(true); + } + + return ret; +} +#endif // Q_OS_BLACKBERRY + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 7ab632d7a0..df78ef6692 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -343,6 +343,14 @@ void qt_nanosleep(timespec amount); Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, const struct timespec *tv); +int qt_select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout); + +#ifdef Q_OS_BLACKBERRY +class QSocketNotifier; +Q_CORE_EXPORT int bb_select(QList<QSocketNotifier *> socketNotifiers, int nfds, fd_set *fdread, + fd_set *fdwrite, int timeout); +#endif // Q_OS_BLACKBERRY + // according to X/OPEN we have to define semun ourselves // we use prefix as on some systems sem.h will have it struct semid_ds; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e8bcc449e9..6868eb6a1e 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -506,7 +506,6 @@ QThread *QCoreApplicationPrivate::mainThread() return theMainThread; } -#if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD) void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) { QThread *currentThread = QThread::currentThread(); @@ -523,7 +522,6 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) Q_UNUSED(currentThread); Q_UNUSED(thr); } -#endif #endif // QT_NO_QOBJECT @@ -2217,6 +2215,9 @@ 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 */ @@ -2294,6 +2295,9 @@ 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() */ /*! @@ -2335,6 +2339,9 @@ 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 */ /*! diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index c3d83112ae..d784267a65 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -116,9 +116,7 @@ public: static QThread *mainThread(); static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data); -#if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD) void checkReceiverThread(QObject *receiver); -#endif void cleanupThreadData(); #endif // QT_NO_QOBJECT diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index aaa75c0fb8..623662a628 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -1264,6 +1264,8 @@ QJNIObjectPrivate QJNIObjectPrivate::callObjectMethod(const char *methodName, jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig); if (id) { res = env->CallObjectMethodV(d->m_jobject, id, args); + if (res && env->ExceptionCheck()) + res = 0; } QJNIObjectPrivate obj(res); @@ -1342,6 +1344,8 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(const char *classNam jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); if (id) { res = env->CallStaticObjectMethodV(clazz, id, args); + if (res && env->ExceptionCheck()) + res = 0; } } @@ -1372,6 +1376,8 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(jclass clazz, jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); if (id) { res = env->CallStaticObjectMethodV(clazz, id, args); + if (res && env->ExceptionCheck()) + res = 0; } QJNIObjectPrivate obj(res); @@ -1685,8 +1691,11 @@ QJNIObjectPrivate QJNIObjectPrivate::getObjectField(const char *fieldName, QJNIEnvironmentPrivate env; jobject res = 0; jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig); - if (id) + if (id) { res = env->GetObjectField(d->m_jobject, id); + if (res && env->ExceptionCheck()) + res = 0; + } QJNIObjectPrivate obj(res); env->DeleteLocalRef(res); @@ -1713,8 +1722,11 @@ QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(jclass clazz, QJNIEnvironmentPrivate env; jobject res = 0; jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); - if (id) + if (id) { res = env->GetStaticObjectField(clazz, id); + if (res && env->ExceptionCheck()) + res = 0; + } QJNIObjectPrivate obj(res); env->DeleteLocalRef(res); diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index a2f203bf7a..7679258a98 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -771,9 +771,13 @@ struct VariantData , flags(flags_) { } + VariantData(const VariantData &other) + : metaTypeId(other.metaTypeId), data(other.data), flags(other.flags){} const int metaTypeId; const void *data; const uint flags; +private: + VariantData &operator=(const VariantData &) Q_DECL_EQ_DELETE; }; template<typename const_iterator> @@ -1702,7 +1706,8 @@ inline int qRegisterMetaTypeStreamOperators() } QT_END_NAMESPACE \ /**/ -#define Q_DECLARE_METATYPE(TYPE) \ +#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE) +#define Q_DECLARE_METATYPE_IMPL(TYPE) \ QT_BEGIN_NAMESPACE \ template <> \ struct QMetaTypeId< TYPE > \ diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h index d2996e6e4d..aea9d41c67 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -132,6 +132,8 @@ namespace QtPrivate { inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, 0); } protected: ~QSlotObjectBase() {} + private: + Q_DISABLE_COPY(QSlotObjectBase) }; // implementation of QSlotObjectBase for which the slot is a pointer to member function of a QObject // Args and R are the List of arguments and the returntype of the signal to which the slot is connected. diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index 59656883f1..40c1157fb4 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -529,8 +529,6 @@ void qt_gui_eval_init(QCoreApplicationPrivate::Type type) box.exec(); ::exit(0); } else { - EvalMessageBox *box = new EvalMessageBox(false); - box->show(); Q_UNUSED(new QGuiFuriCuri()); } } diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 0f5d9a6827..168701d13c 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -187,6 +187,78 @@ QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const QCoreApplication::arguments() before QCommandLineParser defines the \c{profile} option and parses the command line. + \section2 How to Use QCommandLineParser in Complex Applications + + In practice, additional error checking needs to be performed on the positional + arguments and option values. For example, ranges of numbers should be checked. + + It is then advisable to introduce a function to do the command line parsing + which takes a struct or class receiving the option values returning an + enumeration representing the result. The dnslookup example of the QtNetwork + module illustrates this: + + \snippet dnslookup.h 0 + + \snippet dnslookup.cpp 0 + + In the main function, help should be printed to the standard output if the help option + was passed and the application should return the exit code 0. + + If an error was detected, the error message should be printed to the standard + error output and the application should return an exit code other than 0. + + \snippet dnslookup.cpp 1 + + A special case to consider here are GUI applications on Windows and mobile + platforms. These applications may not use the standard output or error channels + since the output is either discarded or not accessible. + + For such GUI applications, it is recommended to display help texts and error messages + using a QMessageBox. To preserve the formatting of the help text, rich text + with \c <pre> elements should be used: + + \code + + switch (parseCommandLine(parser, &query, &errorMessage)) { + case CommandLineOk: + break; + case CommandLineError: +#ifdef Q_OS_WIN + QMessageBox::warning(0, QGuiApplication::applicationDisplayName(), + "<html><head/><body><h2>" + errorMessage + "</h2><pre>" + + parser.helpText() + "</pre></body></html>"); +#else + fputs(qPrintable(errorMessage), stderr); + fputs("\n\n", stderr); + fputs(qPrintable(parser.helpText()), stderr); +#endif + return 1; + case CommandLineVersionRequested: +#ifdef Q_OS_WIN + QMessageBox::information(0, QGuiApplication::applicationDisplayName(), + QGuiApplication::applicationDisplayName() + ' ' + + QCoreApplication::applicationVersion()); +#else + printf("%s %s\n", QGuiApplication::applicationDisplayName(), + qPrintable(QCoreApplication::applicationVersion())); +#endif + return 0; + case CommandLineHelpRequested: +#ifdef Q_OS_WIN + QMessageBox::warning(0, QGuiApplication::applicationDisplayName(), + "<html><head/><body><pre>" + + parser.helpText() + "</pre></body></html>"); + return 0; +#else + parser.showHelp(); + Q_UNREACHABLE(); +#endif + } + \endcode + + However, this does not apply to the dnslookup example, because it is a + console application. + \sa QCommandLineOption, QCoreApplication */ diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 7a421a4586..67924c0888 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -52,6 +52,12 @@ #include <initializer_list> #endif +#if defined(Q_CC_MSVC) +#pragma warning( push ) +#pragma warning( disable : 4311 ) // disable pointer truncation warning +#pragma warning( disable : 4127 ) // conditional expression is constant +#endif + QT_BEGIN_NAMESPACE class QBitArray; @@ -95,18 +101,10 @@ Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QString &key) Q_DECL_NOTHROW; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW; -#if defined(Q_CC_MSVC) -#pragma warning( push ) -#pragma warning( disable : 4311 ) // disable pointer truncation warning -#endif template <class T> inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW { return qHash(reinterpret_cast<quintptr>(key), seed); } -#if defined(Q_CC_MSVC) -#pragma warning( pop ) -#endif - template<typename T> inline uint qHash(const T &t, uint seed) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t))) { return (qHash(t) ^ seed); } @@ -214,6 +212,9 @@ struct QHashNode inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n) : next(n), h(hash), key(key0), value(value0) {} inline bool same_key(uint h0, const Key &key0) const { return h0 == h && key0 == key; } + +private: + Q_DISABLE_COPY(QHashNode) }; template <class Key, class T> @@ -224,6 +225,9 @@ struct QHashDummyNode const Key key; inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {} + +private: + Q_DISABLE_COPY(QHashDummyNode) }; @@ -1087,4 +1091,8 @@ Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash) QT_END_NAMESPACE +#if defined(Q_CC_MSVC) +#pragma warning( pop ) +#endif + #endif // QHASH_H diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 16f058b001..3a0d01aa8d 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -58,6 +58,11 @@ #include <limits.h> #include <string.h> +#ifdef Q_CC_MSVC +#pragma warning( push ) +#pragma warning( disable : 4127 ) // "conditional expression is constant" +#endif + QT_BEGIN_NAMESPACE @@ -937,4 +942,8 @@ Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List) QT_END_NAMESPACE +#ifdef Q_CC_MSVC +#pragma warning( pop ) +#endif + #endif // QLIST_H diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index db0cd6a2d6..487039ccfb 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -260,6 +260,11 @@ QMapNode<Key, T> *QMapNode<Key, T>::copy(QMapData<Key, T> *d) const return n; } +#if defined(Q_CC_MSVC) +#pragma warning( push ) +#pragma warning( disable : 4127 ) // conditional expression is constant +#endif + template <class Key, class T> void QMapNode<Key, T>::destroySubTree() { @@ -275,6 +280,10 @@ void QMapNode<Key, T>::destroySubTree() } } +#if defined(Q_CC_MSVC) +#pragma warning( pop ) +#endif + template <class Key, class T> void QMapData<Key, T>::deleteNode(QMapNode<Key, T> *z) { diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 088f0dc083..03993f05a9 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -312,7 +312,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator+=(const QMargins &margins) + \fn QMargins &QMargins::operator+=(const QMargins &margins) Add each component of \a margins to the respective component of this object and returns a reference to it. @@ -323,7 +323,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator-=(const QMargins &margins) + \fn QMargins &QMargins::operator-=(const QMargins &margins) Subtract each component of \a margins from the respective component of this object and returns a reference to it. @@ -334,7 +334,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator*=(int factor) + \fn QMargins &QMargins::operator*=(int factor) Multiplies each component of this object by \a factor and returns a reference to it. @@ -345,7 +345,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator*=(qreal factor) + \fn QMargins &QMargins::operator*=(qreal factor) \overload Multiplies each component of this object by \a factor @@ -357,7 +357,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator/=(int divisor) + \fn QMargins &QMargins::operator/=(int divisor) Divides each component of this object by \a divisor and returns a reference to it. @@ -368,7 +368,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QMargins &operator/=(qreal divisor) + \fn QMargins &QMargins::operator/=(qreal divisor) \overload diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 1b3a28839c..35c7d1cd3c 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1201,7 +1201,7 @@ bool QRect::intersects(const QRect &r) const */ /*! - \fn QRect QRect::operator+=(const QMargins &margins) const + \fn QRect QRect::operator+=(const QMargins &margins) Adds the \a margins to the rectangle, growing it. @@ -1221,7 +1221,7 @@ bool QRect::intersects(const QRect &r) const */ /*! - \fn QRect QRect::operator -=(const QMargins &margins) const + \fn QRect QRect::operator -=(const QMargins &margins) Returns a rectangle shrunk by the \a margins. diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index d2b5adc974..cadf2da019 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -133,8 +133,8 @@ int qFindString(const QChar *haystack, int haystackLen, int from, or \b{5}. An expression can also be a set of characters enclosed in square brackets. \b{[ABCD]} will match an \b{A} or a \b{B} or a \b{C} or a \b{D}. We can write this same - expression as \b{[A-D]}, and an experession to match any - captital letter in the English alphabet is written as + expression as \b{[A-D]}, and an expression to match any + capital letter in the English alphabet is written as \b{[A-Z]}. A quantifier specifies the number of occurrences of an expression diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 77409f5c71..a610fc46e5 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -478,6 +478,14 @@ */ /*! + \fn void QSharedPointer::swap(QSharedPointer<T> &other); + \since 5.3 + + Swaps this shared pointer instance with \a other. This function is + very fast and never fails. +*/ + +/*! \fn T *QSharedPointer::data() const Returns the value of the pointer referenced by this object. diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 7d1f00814d..34b4bfbb12 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -79,6 +79,8 @@ public: QSharedPointer<T> &operator=(const QSharedPointer<T> &other); QSharedPointer<T> &operator=(const QWeakPointer<T> &other); + void swap(QSharedPointer<T> &other); + QWeakPointer<T> toWeakRef() const; void clear(); diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 9063f59171..cf0726d831 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -870,6 +870,12 @@ inline QString QString::arg(const QString &a1, const QString &a2, const QString inline QString QString::section(QChar asep, int astart, int aend, SectionFlags aflags) const { return section(QString(asep), astart, aend, aflags); } +#ifdef Q_CC_MSVC +// "conditional expression is constant" +#pragma warning(push) +#pragma warning(disable : 4127) +#endif + inline int QString::toWCharArray(wchar_t *array) const { if (sizeof(wchar_t) == sizeof(QChar)) { @@ -878,6 +884,11 @@ inline int QString::toWCharArray(wchar_t *array) const } return toUcs4_helper(d->data(), size(), reinterpret_cast<uint *>(array)); } + +#ifdef Q_CC_MSVC +#pragma warning(pop) +#endif + inline QString QString::fromWCharArray(const wchar_t *string, int size) { return sizeof(wchar_t) == sizeof(QChar) ? fromUtf16(reinterpret_cast<const ushort *>(string), size) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index f0670999d7..befa40081c 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -143,12 +143,16 @@ class QStringBuilder <QString, QString> : public QStringBuilderBase<QStringBuild { public: QStringBuilder(const QString &a_, const QString &b_) : a(a_), b(b_) {} + QStringBuilder(const QStringBuilder &other) : a(other.a), b(other.b) {} operator QString() const { QString r(a); r += b; return r; } const QString &a; const QString &b; + + private: + QStringBuilder &operator=(const QStringBuilder &) Q_DECL_EQ_DELETE; }; template <> @@ -156,12 +160,16 @@ class QStringBuilder <QByteArray, QByteArray> : public QStringBuilderBase<QStrin { public: QStringBuilder(const QByteArray &a_, const QByteArray &b_) : a(a_), b(b_) {} + QStringBuilder(const QStringBuilder &other) : a(other.a), b(other.b) {} operator QByteArray() const { QByteArray r(a); r += b; return r; } const QByteArray &a; const QByteArray &b; + + private: + QStringBuilder &operator=(const QStringBuilder &) Q_DECL_EQ_DELETE; }; diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 3d95377850..49930490ff 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -272,7 +272,6 @@ QSet<QByteArray> QMacTimeZonePrivate::availableTimeZoneIds() const tzid = QCFString::toQString([enumerator nextObject]).toUtf8(); } - [enumerator release]; return set; } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 075e8e83e8..b0be98c296 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -287,6 +287,11 @@ void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom) } } +#if defined(Q_CC_MSVC) +#pragma warning( push ) +#pragma warning( disable : 4127 ) // conditional expression is constant +#endif + template <typename T> void QVector<T>::destruct(T *from, T *to) { @@ -297,6 +302,10 @@ void QVector<T>::destruct(T *from, T *to) } } +#if defined(Q_CC_MSVC) +#pragma warning( pop ) +#endif + template <typename T> inline QVector<T>::QVector(const QVector<T> &v) { |