From 4e9853139ca04858f1639e0fba6b8caf57474f29 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 13 May 2014 16:49:33 +0200 Subject: Update Copyright year in commercial nag screens Change-Id: I70420c44c018dbe733a50badb7f9f7f419459f7a Reviewed-by: Lars Knoll --- src/corelib/kernel/qtcore_eval.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index 40c1157fb4..a5c4c36638 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE static const char boilerplate_supported_but_time_limited[] = "\nQt %1 Evaluation License\n" - "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n" + "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" "This trial version may only be used for evaluation purposes\n" "and will shut down after 120 minutes.\n" "Registered to:\n" @@ -65,7 +65,7 @@ static const char boilerplate_supported_but_time_limited[] = static const char boilerplate_supported[] = "\nQt %1 Evaluation License\n" - "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n" + "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" "This trial version may only be used for evaluation purposes\n" "Registered to:\n" " Licensee: %2\n\n" -- cgit v1.2.3 From bbdf6a8039c19d63537d4ac056d1f3830550b362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 28 Apr 2014 01:55:45 +0200 Subject: Android: Use exceptionCheck() function. This was the only place where we didn't use the exceptionCheck() function. Besides being more consistent, it's also more verbose if an exception occurs. Change-Id: Ib1e3dba82b0730cf189ec725f4da425d7ac85cdc Reviewed-by: Yoann Lopes --- src/corelib/kernel/qjnihelpers.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index 311ebaa092..cbd3d776a7 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -113,10 +113,8 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env) { jclass jQtNative = env->FindClass("org/qtproject/qt5/android/QtNative"); - if (env->ExceptionCheck()) { - env->ExceptionClear(); + if (exceptionCheck(env)) return JNI_ERR; - } jmethodID activityMethodID = env->GetStaticMethodID(jQtNative, "activity", -- cgit v1.2.3 From 7ec49393131461e07554f37042db16b5462a5565 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 5 Jun 2014 16:42:58 +0200 Subject: Fix documentation about QStringLiteral The fallback for QStringLiteral in case C++11 features are not enabled is QString::fromUtf8(), not QLatin1String(). Also, the result of a QStringLiteral expression _is_ a QString. Change-Id: Ib9c2f4c13fff237de3acb2e0f64027bacea6271c Reviewed-by: Giuseppe D'Angelo Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index aac9c493c3..a018b81c38 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9872,9 +9872,7 @@ QString QString::toHtmlEscaped() const the read-only segment of the compiled object file. For compilers not supporting the creation of compile time strings, QStringLiteral will fall back to - QLatin1String. - - The result of the QStringLiteral expression can be cast into a QString. + QString::fromUtf8(). If you have code looking like: \code -- cgit v1.2.3 From 29513210dfaf4252c67d7142737e41491297911d Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 9 Jun 2014 10:54:27 +0200 Subject: Doc: QAtomicInteger first appeared in Qt 5.3 Change-Id: I900e5b0ec8291d34685cb545540a5a9f54551d05 Reviewed-by: Thiago Macieira --- src/corelib/thread/qatomic.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index 33e85c1505..b2043a45a1 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -58,6 +58,7 @@ \inmodule QtCore \brief The QAtomicInteger class provides platform-independent atomic operations on integers. \ingroup thread + \since 5.3 For atomic operations on pointers, see the QAtomicPointer class. -- cgit v1.2.3 From 641ca1d7cbdef919130411ff1999229d2e477327 Mon Sep 17 00:00:00 2001 From: Steffen Imhof Date: Wed, 28 May 2014 14:14:39 +0200 Subject: Fix QT_NO_SETTINGS build in QLibraryInfo. One reference to QSettings was only guarded by QT_BOOTSTRAPPED. Change-Id: I2f9761ee88b4a45edb16054fdba3c3f11fec12ff Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlibraryinfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 6d25325890..174c1d0d8d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -537,7 +537,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) { -#ifndef QT_BOOTSTRAPPED +#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_SETTINGS) if (const QSettings *settings = QLibraryInfoPrivate::findConfiguration()) { QString key = QLatin1String(platformsSection); key += QLatin1Char('/'); @@ -545,7 +545,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) key += QLatin1String("Arguments"); return settings->value(key).toStringList(); } -#endif // !QT_BOOTSTRAPPED +#endif // !QT_BOOTSTRAPPED && !QT_NO_SETTINGS return QStringList(); } -- cgit v1.2.3 From 81ba16cad933981f55218964a89ed1446022efba Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 24 Mar 2014 16:12:20 +0100 Subject: Fix case insensitive comparisons using QCollator In ICU the strength parameter decides whether a comparison is case sensitive or not. Fix mac comparison code. It can't have worked before. Added some basic automated testing for QCollator. Change-Id: I2646c464fd22ccd3a93c461fa3dba4bd1d4c7b4b Reviewed-by: Konstantin Ritt --- src/corelib/tools/qcollator_icu.cpp | 11 +++++++++-- src/corelib/tools/qcollator_macx.cpp | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 407a493d25..23e88b5015 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -75,10 +75,17 @@ void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs) { detach(); - UColAttributeValue val = (cs == Qt::CaseSensitive) ? UCOL_UPPER_FIRST : UCOL_OFF; + // The strength attribute in ICU is rather badly documented. Basically UCOL_PRIMARY + // ignores differences between base characters and accented characters as well as case. + // So A and A-umlaut would compare equal. + // UCOL_SECONDARY ignores case differences. UCOL_TERTIARY is the default in most languages + // and does case sensitive comparison. + // UCOL_QUATERNARY is used as default in a few languages such as Japanese to take care of some + // additional differences in those languages. + UColAttributeValue val = (cs == Qt::CaseSensitive) ? UCOL_DEFAULT_STRENGTH : UCOL_SECONDARY; UErrorCode status = U_ZERO_ERROR; - ucol_setAttribute(d->collator, UCOL_CASE_FIRST, val, &status); + ucol_setAttribute(d->collator, UCOL_STRENGTH, val, &status); if (U_FAILURE(status)) qWarning("ucol_setAttribute: Case First failed: %d", status); } diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index 8985cd4eba..877510489a 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -128,12 +128,15 @@ bool QCollator::ignorePunctuation() const int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const { SInt32 result; - return UCCompareText(d->collator.collator, + Boolean equivalent; + UCCompareText(d->collator.collator, reinterpret_cast(s1), len1, reinterpret_cast(s2), len2, - NULL, + &equivalent, &result); - return result; + if (equivalent) + return 0; + return result < 0 ? -1 : 1; } int QCollator::compare(const QString &str1, const QString &str2) const { -- cgit v1.2.3 From 02b7b21f9bafcba3231610fef31b590474567472 Mon Sep 17 00:00:00 2001 From: Zhang Xingtao Date: Thu, 12 Jun 2014 19:11:35 +0800 Subject: Doc: correct the format of Q_PLUGIN_METADATA macro in sample codes Change-Id: I464a0c0a590b0b90cf0fe7ccd448ee9bf704bd4f Reviewed-by: Olivier Goffart --- src/corelib/doc/snippets/code/doc_src_plugins-howto.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/code/doc_src_plugins-howto.cpp b/src/corelib/doc/snippets/code/doc_src_plugins-howto.cpp index aae4f4bd00..b86f0bbf68 100644 --- a/src/corelib/doc/snippets/code/doc_src_plugins-howto.cpp +++ b/src/corelib/doc/snippets/code/doc_src_plugins-howto.cpp @@ -42,7 +42,7 @@ class MyStylePlugin : public QStylePlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE mystyleplugin.json) + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "mystyleplugin.json") public: QStyle *create(const QString &key); }; -- cgit v1.2.3 From 29f92d112af6deb3597a6b80e3259e826911dcca Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 14:51:44 -0700 Subject: Move the QProcessPrivate channel buffers into QProcessPrivate::Channel Simplifies the code. Change-Id: I70b26af69332f364d856042f114c37a70504d66f Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 56 ++++++++++++++++++++-------------------- src/corelib/io/qprocess_p.h | 5 +--- src/corelib/io/qprocess_unix.cpp | 8 +++--- src/corelib/io/qprocess_win.cpp | 8 +++--- 4 files changed, 37 insertions(+), 40 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 9f9cba81ab..24ee3b6c0b 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -916,7 +916,7 @@ bool QProcessPrivate::_q_canReadStandardOutput() return false; } - char *ptr = outputReadBuffer.reserve(available); + char *ptr = stdoutChannel.buffer.reserve(available); qint64 readBytes = readFromStdout(ptr, available); if (readBytes == -1) { processError = QProcess::ReadError; @@ -933,11 +933,11 @@ bool QProcessPrivate::_q_canReadStandardOutput() #endif if (stdoutChannel.closed) { - outputReadBuffer.chop(readBytes); + stdoutChannel.buffer.chop(readBytes); return false; } - outputReadBuffer.chop(available - readBytes); + stdoutChannel.buffer.chop(available - readBytes); bool didRead = false; if (readBytes == 0) { @@ -969,7 +969,7 @@ bool QProcessPrivate::_q_canReadStandardError() return false; } - char *ptr = errorReadBuffer.reserve(available); + char *ptr = stderrChannel.buffer.reserve(available); qint64 readBytes = readFromStderr(ptr, available); if (readBytes == -1) { processError = QProcess::ReadError; @@ -978,11 +978,11 @@ bool QProcessPrivate::_q_canReadStandardError() return false; } if (stderrChannel.closed) { - errorReadBuffer.chop(readBytes); + stderrChannel.buffer.chop(readBytes); return false; } - errorReadBuffer.chop(available - readBytes); + stderrChannel.buffer.chop(available - readBytes); bool didRead = false; if (readBytes == 0) { @@ -1009,15 +1009,15 @@ bool QProcessPrivate::_q_canWrite() if (stdinChannel.notifier) stdinChannel.notifier->setEnabled(false); - if (writeBuffer.isEmpty()) { + if (stdinChannel.buffer.isEmpty()) { #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::canWrite(), not writing anything (empty write buffer)."); #endif return false; } - qint64 written = writeToStdin(writeBuffer.readPointer(), - writeBuffer.nextDataBlockSize()); + qint64 written = writeToStdin(stdinChannel.buffer.readPointer(), + stdinChannel.buffer.nextDataBlockSize()); if (written < 0) { destroyChannel(&stdinChannel); processError = QProcess::WriteError; @@ -1031,16 +1031,16 @@ bool QProcessPrivate::_q_canWrite() #endif if (written != 0) { - writeBuffer.free(written); + stdinChannel.buffer.free(written); if (!emittedBytesWritten) { emittedBytesWritten = true; emit q->bytesWritten(written); emittedBytesWritten = false; } } - if (stdinChannel.notifier && !writeBuffer.isEmpty()) + if (stdinChannel.notifier && !stdinChannel.buffer.isEmpty()) stdinChannel.notifier->setEnabled(true); - if (writeBuffer.isEmpty() && stdinChannel.closed) + if (stdinChannel.buffer.isEmpty() && stdinChannel.closed) closeWriteChannel(); return true; } @@ -1308,10 +1308,10 @@ void QProcess::setReadChannel(ProcessChannel channel) QByteArray buf = d->buffer.readAll(); if (d->processChannel == QProcess::StandardOutput) { for (int i = buf.size() - 1; i >= 0; --i) - d->outputReadBuffer.ungetChar(buf.at(i)); + d->stdoutChannel.buffer.ungetChar(buf.at(i)); } else { for (int i = buf.size() - 1; i >= 0; --i) - d->errorReadBuffer.ungetChar(buf.at(i)); + d->stderrChannel.buffer.ungetChar(buf.at(i)); } } d->processChannel = channel; @@ -1359,7 +1359,7 @@ void QProcess::closeWriteChannel() { Q_D(QProcess); d->stdinChannel.closed = true; // closing - if (d->writeBuffer.isEmpty()) + if (d->stdinChannel.buffer.isEmpty()) d->closeWriteChannel(); } @@ -1589,8 +1589,8 @@ bool QProcess::canReadLine() const { Q_D(const QProcess); const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) - ? &d->errorReadBuffer - : &d->outputReadBuffer; + ? &d->stderrChannel.buffer + : &d->stdoutChannel.buffer; return readBuffer->canReadLine() || QIODevice::canReadLine(); } @@ -1618,8 +1618,8 @@ bool QProcess::atEnd() const { Q_D(const QProcess); const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) - ? &d->errorReadBuffer - : &d->outputReadBuffer; + ? &d->stderrChannel.buffer + : &d->stdoutChannel.buffer; return QIODevice::atEnd() && (!isOpen() || readBuffer->isEmpty()); } @@ -1636,8 +1636,8 @@ qint64 QProcess::bytesAvailable() const { Q_D(const QProcess); const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) - ? &d->errorReadBuffer - : &d->outputReadBuffer; + ? &d->stderrChannel.buffer + : &d->stdoutChannel.buffer; #if defined QPROCESS_DEBUG qDebug("QProcess::bytesAvailable() == %i (%s)", readBuffer->size(), (d->processChannel == QProcess::StandardError) ? "stderr" : "stdout"); @@ -1650,7 +1650,7 @@ qint64 QProcess::bytesAvailable() const qint64 QProcess::bytesToWrite() const { Q_D(const QProcess); - qint64 size = d->writeBuffer.size(); + qint64 size = d->stdinChannel.buffer.size(); #ifdef Q_OS_WIN size += d->pipeWriterBytesToWrite(); #endif @@ -1897,8 +1897,8 @@ qint64 QProcess::readData(char *data, qint64 maxlen) if (!maxlen) return 0; QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) - ? &d->errorReadBuffer - : &d->outputReadBuffer; + ? &d->stderrChannel.buffer + : &d->stdoutChannel.buffer; if (maxlen == 1 && !readBuffer->isEmpty()) { int c = readBuffer->getChar(); @@ -1961,7 +1961,7 @@ qint64 QProcess::writeData(const char *data, qint64 len) } if (len == 1) { - d->writeBuffer.putChar(*data); + d->stdinChannel.buffer.putChar(*data); if (d->stdinChannel.notifier) d->stdinChannel.notifier->setEnabled(true); #if defined QPROCESS_DEBUG @@ -1971,7 +1971,7 @@ qint64 QProcess::writeData(const char *data, qint64 len) return 1; } - char *dest = d->writeBuffer.reserve(len); + char *dest = d->stdinChannel.buffer.reserve(len); memcpy(dest, data, len); if (d->stdinChannel.notifier) d->stdinChannel.notifier->setEnabled(true); @@ -2112,8 +2112,8 @@ void QProcessPrivate::start(QIODevice::OpenMode mode) qDebug() << "QProcess::start(" << program << ',' << arguments << ',' << mode << ')'; #endif - outputReadBuffer.clear(); - errorReadBuffer.clear(); + stdoutChannel.buffer.clear(); + stderrChannel.buffer.clear(); if (stdinChannel.type != QProcessPrivate::Channel::Normal) mode &= ~QIODevice::WriteOnly; // not open for writing diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 5d65b2a068..552ef5698b 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -282,6 +282,7 @@ public: QString file; QProcessPrivate *process; QSocketNotifier *notifier; + QRingBuffer buffer; Q_PIPE pipe[2]; unsigned type : 2; @@ -326,10 +327,6 @@ public: #endif QProcessEnvironment environment; - QRingBuffer outputReadBuffer; - QRingBuffer errorReadBuffer; - QRingBuffer writeBuffer; - Q_PIPE childStartedPipe[2]; Q_PIPE deathPipe[2]; void destroyPipe(Q_PIPE pipe[2]); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 8674371baa..97e8add9fa 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1126,7 +1126,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs) if (stderrChannel.pipe[0] != -1) add_fd(nfds, stderrChannel.pipe[0], &fdread); - if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) + if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); @@ -1188,7 +1188,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) QList notifiers = defaultNotifiers(); #endif - while (!writeBuffer.isEmpty()) { + while (!stdinChannel.buffer.isEmpty()) { fd_set fdread; fd_set fdwrite; @@ -1207,7 +1207,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) add_fd(nfds, stderrChannel.pipe[0], &fdread); - if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) + if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); @@ -1282,7 +1282,7 @@ bool QProcessPrivate::waitForFinished(int msecs) if (processState == QProcess::Running) add_fd(nfds, deathPipe[0], &fdread); - if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) + if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index d7050034bd..43233b27bd 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -690,7 +690,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs) QIncrementalSleepTimer timer(msecs); forever { - if (!writeBuffer.isEmpty() && !_q_canWrite()) + if (!stdinChannel.buffer.isEmpty() && !_q_canWrite()) return false; if (pipeWriter && pipeWriter->waitForWrite(0)) timer.resetIncrements(); @@ -731,7 +731,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) // If we don't have pending data, and our write buffer is // empty, we fail. - if (!pendingDataInPipe && writeBuffer.isEmpty()) + if (!pendingDataInPipe && stdinChannel.buffer.isEmpty()) return false; // If we don't have pending data and we do have data in our @@ -795,7 +795,7 @@ bool QProcessPrivate::waitForFinished(int msecs) QIncrementalSleepTimer timer(msecs); forever { - if (!writeBuffer.isEmpty() && !_q_canWrite()) + if (!stdinChannel.buffer.isEmpty() && !_q_canWrite()) return false; if (pipeWriter && pipeWriter->waitForWrite(0)) timer.resetIncrements(); @@ -875,7 +875,7 @@ void QProcessPrivate::_q_notified() { notifier->stop(); - if (!writeBuffer.isEmpty() && (!pipeWriter || pipeWriter->waitForWrite(0))) + if (!stdinChannel.buffer.isEmpty() && (!pipeWriter || pipeWriter->waitForWrite(0))) _q_canWrite(); if (processState != QProcess::NotRunning) -- cgit v1.2.3 From 15a0a6e8c54ad52fe9f02e637f6a977fa794257b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 15:05:56 -0700 Subject: Move the QProcessPrivate Windows objects into QProcessPrivate::Channel Similar to the previous commit, this simplifies the code. Change-Id: Ia02b9b5174b4bc6fd04ec2534231b7db5fc914fa Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 3 -- src/corelib/io/qprocess_p.h | 12 +++-- src/corelib/io/qprocess_win.cpp | 108 +++++++++++++++++----------------------- 3 files changed, 56 insertions(+), 67 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 24ee3b6c0b..cfe5a68fc8 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -819,9 +819,6 @@ QProcessPrivate::QProcessPrivate() emittedBytesWritten = false; #ifdef Q_OS_WIN notifier = 0; - stdoutReader = 0; - stderrReader = 0; - pipeWriter = 0; processFinishedNotifier = 0; #endif // Q_OS_WIN #ifdef Q_OS_UNIX diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 552ef5698b..e76a769073 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -253,6 +253,9 @@ public: { pipe[0] = INVALID_Q_PIPE; pipe[1] = INVALID_Q_PIPE; +#ifdef Q_OS_WIN + reader = 0; +#endif } void clear(); @@ -282,6 +285,12 @@ public: QString file; QProcessPrivate *process; QSocketNotifier *notifier; +#ifdef Q_OS_WIN + union { + QWindowsPipeReader *reader; + QWindowsPipeWriter *writer; + }; +#endif QRingBuffer buffer; Q_PIPE pipe[2]; @@ -338,9 +347,6 @@ public: #ifdef Q_OS_WIN // the wonderful windows notifier QTimer *notifier; - QWindowsPipeReader *stdoutReader; - QWindowsPipeReader *stderrReader; - QWindowsPipeWriter *pipeWriter; QWinEventNotifier *processFinishedNotifier; #endif diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 43233b27bd..8aa31cb42e 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -180,34 +180,31 @@ bool QProcessPrivate::createChannel(Channel &channel) &channel.pipe[0], 0, TRUE, DUPLICATE_SAME_ACCESS); } } else { - QWindowsPipeReader *pipeReader = 0; if (&channel == &stdoutChannel) { if (processChannelMode != QProcess::ForwardedChannels && processChannelMode != QProcess::ForwardedOutputChannel) { - if (!stdoutReader) { - stdoutReader = new QWindowsPipeReader(q); - q->connect(stdoutReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardOutput())); + if (!stdoutChannel.reader) { + stdoutChannel.reader = new QWindowsPipeReader(q); + q->connect(stdoutChannel.reader, SIGNAL(readyRead()), SLOT(_q_canReadStandardOutput())); } - pipeReader = stdoutReader; } else { duplicateStdWriteChannel(channel.pipe, STD_OUTPUT_HANDLE); } } else /* if (&channel == &stderrChannel) */ { if (processChannelMode != QProcess::ForwardedChannels && processChannelMode != QProcess::ForwardedErrorChannel) { - if (!stderrReader) { - stderrReader = new QWindowsPipeReader(q); - q->connect(stderrReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardError())); + if (!stderrChannel.reader) { + stderrChannel.reader = new QWindowsPipeReader(q); + q->connect(stderrChannel.reader, SIGNAL(readyRead()), SLOT(_q_canReadStandardError())); } - pipeReader = stderrReader; } else { duplicateStdWriteChannel(channel.pipe, STD_ERROR_HANDLE); } } - if (pipeReader) { + if (channel.reader) { qt_create_pipe(channel.pipe, false); - pipeReader->setHandle(channel.pipe[0]); - pipeReader->startAsyncRead(); + channel.reader->setHandle(channel.pipe[0]); + channel.reader->startAsyncRead(); } } @@ -335,22 +332,12 @@ void QProcessPrivate::destroyPipe(Q_PIPE pipe[2]) void QProcessPrivate::destroyChannel(Channel *channel) { if (channel == &stdinChannel) { - if (pipeWriter) { - delete pipeWriter; - pipeWriter = 0; - } - } else if (channel == &stdoutChannel) { - if (stdoutReader) { - stdoutReader->stop(); - stdoutReader->deleteLater(); - stdoutReader = 0; - } - } else if (channel == &stderrChannel) { - if (stderrReader) { - stderrReader->stop(); - stderrReader->deleteLater(); - stderrReader = 0; - } + delete stdinChannel.writer; + stdinChannel.writer = 0; + } else if (channel->reader) { + channel->reader->stop(); + channel->reader->deleteLater(); + channel->reader = 0; } destroyPipe(channel->pipe); } @@ -582,10 +569,10 @@ qint64 QProcessPrivate::bytesAvailableFromStdout() const if (stdoutChannel.pipe[0] == INVALID_Q_PIPE) return 0; - if (!stdoutReader) + if (!stdoutChannel.reader) return 0; - DWORD bytesAvail = stdoutReader->bytesAvailable(); + DWORD bytesAvail = stdoutChannel.reader->bytesAvailable(); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::bytesAvailableFromStdout() == %d", bytesAvail); #endif @@ -597,10 +584,10 @@ qint64 QProcessPrivate::bytesAvailableFromStderr() const if (stderrChannel.pipe[0] == INVALID_Q_PIPE) return 0; - if (!stderrReader) + if (!stderrChannel.reader) return 0; - DWORD bytesAvail = stderrReader->bytesAvailable(); + DWORD bytesAvail = stderrChannel.reader->bytesAvailable(); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::bytesAvailableFromStderr() == %d", bytesAvail); #endif @@ -609,12 +596,12 @@ qint64 QProcessPrivate::bytesAvailableFromStderr() const qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen) { - return stdoutReader ? stdoutReader->read(data, maxlen) : 0; + return stdoutChannel.reader ? stdoutChannel.reader->read(data, maxlen) : 0; } qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen) { - return stderrReader ? stderrReader->read(data, maxlen) : 0; + return stderrChannel.reader ? stderrChannel.reader->read(data, maxlen) : 0; } @@ -659,20 +646,20 @@ bool QProcessPrivate::waitForStarted(int) bool QProcessPrivate::drainOutputPipes() { - if (!stdoutReader && !stderrReader) + if (!stdoutChannel.reader && !stderrChannel.reader) return false; bool someReadyReadEmitted = false; forever { bool readyReadEmitted = false; bool readOperationActive = false; - if (stdoutReader) { - readyReadEmitted |= stdoutReader->waitForReadyRead(0); - readOperationActive = stdoutReader && stdoutReader->isReadOperationActive(); + if (stdoutChannel.reader) { + readyReadEmitted |= stdoutChannel.reader->waitForReadyRead(0); + readOperationActive = stdoutChannel.reader && stdoutChannel.reader->isReadOperationActive(); } - if (stderrReader) { - readyReadEmitted |= stderrReader->waitForReadyRead(0); - readOperationActive |= stderrReader && stderrReader->isReadOperationActive(); + if (stderrChannel.reader) { + readyReadEmitted |= stderrChannel.reader->waitForReadyRead(0); + readOperationActive |= stderrChannel.reader && stderrChannel.reader->isReadOperationActive(); } someReadyReadEmitted |= readyReadEmitted; if (!readOperationActive || !readyReadEmitted) @@ -692,11 +679,11 @@ bool QProcessPrivate::waitForReadyRead(int msecs) forever { if (!stdinChannel.buffer.isEmpty() && !_q_canWrite()) return false; - if (pipeWriter && pipeWriter->waitForWrite(0)) + if (stdinChannel.writer && stdinChannel.writer->waitForWrite(0)) timer.resetIncrements(); - if ((stdoutReader && stdoutReader->waitForReadyRead(0)) - || (stderrReader && stderrReader->waitForReadyRead(0))) + if ((stdoutChannel.reader && stdoutChannel.reader->waitForReadyRead(0)) + || (stderrChannel.reader && stderrChannel.reader->waitForReadyRead(0))) return true; if (!pid) @@ -726,8 +713,8 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) forever { // Check if we have any data pending: the pipe writer has // bytes waiting to written, or it has written data since the - // last time we called pipeWriter->waitForWrite(). - bool pendingDataInPipe = pipeWriter && (pipeWriter->bytesToWrite() || pipeWriter->hadWritten()); + // last time we called stdinChannel.writer->waitForWrite(). + bool pendingDataInPipe = stdinChannel.writer && (stdinChannel.writer->bytesToWrite() || stdinChannel.writer->hadWritten()); // If we don't have pending data, and our write buffer is // empty, we fail. @@ -746,10 +733,10 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) // written. This will succeed if either the pipe writer has // already written the data, or if it manages to write data // within the given timeout. If the write buffer was non-empty - // and the pipeWriter is now dead, that means _q_canWrite() + // and the stdinChannel.writer is now dead, that means _q_canWrite() // destroyed the writer after it successfully wrote the last // batch. - if (!pipeWriter || pipeWriter->waitForWrite(0)) + if (!stdinChannel.writer || stdinChannel.writer->waitForWrite(0)) return true; // If we wouldn't write anything, check if we can read stdout. @@ -797,11 +784,11 @@ bool QProcessPrivate::waitForFinished(int msecs) forever { if (!stdinChannel.buffer.isEmpty() && !_q_canWrite()) return false; - if (pipeWriter && pipeWriter->waitForWrite(0)) + if (stdinChannel.writer && stdinChannel.writer->waitForWrite(0)) timer.resetIncrements(); - if (stdoutReader && stdoutReader->waitForReadyRead(0)) + if (stdoutChannel.reader && stdoutChannel.reader->waitForReadyRead(0)) timer.resetIncrements(); - if (stderrReader && stderrReader->waitForReadyRead(0)) + if (stderrChannel.reader && stderrChannel.reader->waitForReadyRead(0)) timer.resetIncrements(); if (!pid) { @@ -837,33 +824,32 @@ void QProcessPrivate::findExitCode() void QProcessPrivate::flushPipeWriter() { - if (pipeWriter && pipeWriter->bytesToWrite() > 0) { - pipeWriter->waitForWrite(ULONG_MAX); - } + if (stdinChannel.writer && stdinChannel.writer->bytesToWrite() > 0) + stdinChannel.writer->waitForWrite(ULONG_MAX); } qint64 QProcessPrivate::pipeWriterBytesToWrite() const { - return pipeWriter ? pipeWriter->bytesToWrite() : qint64(0); + return stdinChannel.writer ? stdinChannel.writer->bytesToWrite() : qint64(0); } qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) { Q_Q(QProcess); - if (!pipeWriter) { - pipeWriter = new QWindowsPipeWriter(stdinChannel.pipe[1], q); - pipeWriter->start(); + if (!stdinChannel.writer) { + stdinChannel.writer = new QWindowsPipeWriter(stdinChannel.pipe[1], q); + stdinChannel.writer->start(); } - return pipeWriter->write(data, maxlen); + return stdinChannel.writer->write(data, maxlen); } bool QProcessPrivate::waitForWrite(int msecs) { Q_Q(QProcess); - if (!pipeWriter || pipeWriter->waitForWrite(msecs)) + if (!stdinChannel.writer || stdinChannel.writer->waitForWrite(msecs)) return true; processError = QProcess::Timedout; @@ -875,7 +861,7 @@ void QProcessPrivate::_q_notified() { notifier->stop(); - if (!stdinChannel.buffer.isEmpty() && (!pipeWriter || pipeWriter->waitForWrite(0))) + if (!stdinChannel.buffer.isEmpty() && (!stdinChannel.writer || stdinChannel.writer->waitForWrite(0))) _q_canWrite(); if (processState != QProcess::NotRunning) -- cgit v1.2.3 From 0f6b3a01e4c6fc7e4c2603b3dfcf3c0f81090ba9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 14:32:02 -0700 Subject: Rename QProcessPrivate::destroyChannel to closeChannel The QProcessPrivate::Channel object contains some structures that may survive the closing of the pipe, so calling this function "destroy" is incorrect. Let it be just the closing. For symmetry, the createChannel() function is renamed to openChannel(). Change-Id: I2899214c6e4c25835390b10ccf3931315a91589e Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 14 +++++++------- src/corelib/io/qprocess_p.h | 4 ++-- src/corelib/io/qprocess_unix.cpp | 10 +++++----- src/corelib/io/qprocess_win.cpp | 10 +++++----- src/corelib/io/qprocess_wince.cpp | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index cfe5a68fc8..a3fca5bfe0 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -886,9 +886,9 @@ void QProcessPrivate::cleanup() notifier = 0; } #endif - destroyChannel(&stdoutChannel); - destroyChannel(&stderrChannel); - destroyChannel(&stdinChannel); + closeChannel(&stdoutChannel); + closeChannel(&stderrChannel); + closeChannel(&stdinChannel); destroyPipe(childStartedPipe); destroyPipe(deathPipe); #ifdef Q_OS_UNIX @@ -906,7 +906,7 @@ bool QProcessPrivate::_q_canReadStandardOutput() if (available == 0) { if (stdoutChannel.notifier) stdoutChannel.notifier->setEnabled(false); - destroyChannel(&stdoutChannel); + closeChannel(&stdoutChannel); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::canReadStandardOutput(), 0 bytes available"); #endif @@ -962,7 +962,7 @@ bool QProcessPrivate::_q_canReadStandardError() if (available == 0) { if (stderrChannel.notifier) stderrChannel.notifier->setEnabled(false); - destroyChannel(&stderrChannel); + closeChannel(&stderrChannel); return false; } @@ -1016,7 +1016,7 @@ bool QProcessPrivate::_q_canWrite() qint64 written = writeToStdin(stdinChannel.buffer.readPointer(), stdinChannel.buffer.nextDataBlockSize()); if (written < 0) { - destroyChannel(&stdinChannel); + closeChannel(&stdinChannel); processError = QProcess::WriteError; q->setErrorString(QProcess::tr("Error writing to process")); emit q->error(processError); @@ -1160,7 +1160,7 @@ void QProcessPrivate::closeWriteChannel() // instead. flushPipeWriter(); #endif - destroyChannel(&stdinChannel); + closeChannel(&stdinChannel); } /*! diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index e76a769073..c491c57abc 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -326,7 +326,8 @@ public: Channel stdinChannel; Channel stdoutChannel; Channel stderrChannel; - bool createChannel(Channel &channel); + bool openChannel(Channel &channel); + void closeChannel(Channel *channel); void closeWriteChannel(); QString program; @@ -339,7 +340,6 @@ public: Q_PIPE childStartedPipe[2]; Q_PIPE deathPipe[2]; void destroyPipe(Q_PIPE pipe[2]); - void destroyChannel(Channel *channel); QSocketNotifier *startupSocketNotifier; QSocketNotifier *deathNotifier; diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 97e8add9fa..4147191f08 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -377,7 +377,7 @@ void QProcessPrivate::destroyPipe(int *pipe) } } -void QProcessPrivate::destroyChannel(Channel *channel) +void QProcessPrivate::closeChannel(Channel *channel) { destroyPipe(channel->pipe); } @@ -387,7 +387,7 @@ void QProcessPrivate::destroyChannel(Channel *channel) This function must be called in order: stdin, stdout, stderr */ -bool QProcessPrivate::createChannel(Channel &channel) +bool QProcessPrivate::openChannel(Channel &channel) { Q_Q(QProcess); @@ -573,9 +573,9 @@ void QProcessPrivate::startProcess() processManager()->start(); // Initialize pipes - if (!createChannel(stdinChannel) || - !createChannel(stdoutChannel) || - !createChannel(stderrChannel) || + if (!openChannel(stdinChannel) || + !openChannel(stdoutChannel) || + !openChannel(stderrChannel) || qt_create_pipe(childStartedPipe) != 0 || qt_create_pipe(deathPipe) != 0) { processError = QProcess::FailedToStart; diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 8aa31cb42e..61cf21751e 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -158,7 +158,7 @@ static void duplicateStdWriteChannel(Q_PIPE *pipe, DWORD nStdHandle) This function must be called in order: stdin, stdout, stderr */ -bool QProcessPrivate::createChannel(Channel &channel) +bool QProcessPrivate::openChannel(Channel &channel) { Q_Q(QProcess); @@ -329,7 +329,7 @@ void QProcessPrivate::destroyPipe(Q_PIPE pipe[2]) } } -void QProcessPrivate::destroyChannel(Channel *channel) +void QProcessPrivate::closeChannel(Channel *channel) { if (channel == &stdinChannel) { delete stdinChannel.writer; @@ -473,9 +473,9 @@ void QProcessPrivate::startProcess() q->setProcessState(QProcess::Starting); - if (!createChannel(stdinChannel) || - !createChannel(stdoutChannel) || - !createChannel(stderrChannel)) + if (!openChannel(stdinChannel) || + !openChannel(stdoutChannel) || + !openChannel(stderrChannel)) return; QString args = qt_create_commandline(program, arguments); diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp index ad9a328133..b1c41ff069 100644 --- a/src/corelib/io/qprocess_wince.cpp +++ b/src/corelib/io/qprocess_wince.cpp @@ -62,7 +62,7 @@ void QProcessPrivate::destroyPipe(Q_PIPE pipe[2]) Q_UNUSED(pipe); } -void QProcessPrivate::destroyChannel(Channel *channel) +void QProcessPrivate::closeChannel(Channel *channel) { Q_UNUSED(channel); } -- cgit v1.2.3 From 25ef58fe185f1534d9d89aee72e84c3789068907 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 15:10:27 -0700 Subject: QProcessPrivate: merge the functions dealing with stdout and stderr Simplifies the code. Change-Id: I4b3a6e725eb245d3531d1d11d959fb3b85862778 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 86 ++++++++++++++------------------------- src/corelib/io/qprocess_p.h | 7 ++-- src/corelib/io/qprocess_unix.cpp | 35 ++++------------ src/corelib/io/qprocess_win.cpp | 43 +++++--------------- src/corelib/io/qprocess_wince.cpp | 14 +------ 5 files changed, 54 insertions(+), 131 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index a3fca5bfe0..615e584f81 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -898,49 +898,51 @@ void QProcessPrivate::cleanup() /*! \internal + Returns true if we emitted readyRead(). */ -bool QProcessPrivate::_q_canReadStandardOutput() +bool QProcessPrivate::tryReadFromChannel(Channel *channel) { Q_Q(QProcess); - qint64 available = bytesAvailableFromStdout(); + qint64 available = bytesAvailableInChannel(channel); if (available == 0) { - if (stdoutChannel.notifier) - stdoutChannel.notifier->setEnabled(false); - closeChannel(&stdoutChannel); + if (channel->notifier) + channel->notifier->setEnabled(false); + closeChannel(channel); #if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::canReadStandardOutput(), 0 bytes available"); + qDebug("QProcessPrivate::tryReadFromChannel(%d), 0 bytes available", channel - &stdinChannel); #endif return false; } - char *ptr = stdoutChannel.buffer.reserve(available); - qint64 readBytes = readFromStdout(ptr, available); + char *ptr = channel->buffer.reserve(available); + qint64 readBytes = readFromChannel(channel, ptr, available); if (readBytes == -1) { processError = QProcess::ReadError; q->setErrorString(QProcess::tr("Error reading from process")); emit q->error(processError); #if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::canReadStandardOutput(), failed to read from the process"); + qDebug("QProcessPrivate::tryReadFromChannel(%d), failed to read from the process", channel - &stdinChannel); #endif return false; } #if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::canReadStandardOutput(), read %d bytes from the process' output", + qDebug("QProcessPrivate::tryReadFromChannel(%d), read %d bytes from the process' output", channel - &stdinChannel int(readBytes)); #endif - if (stdoutChannel.closed) { - stdoutChannel.buffer.chop(readBytes); + if (channel->closed) { + channel->buffer.chop(readBytes); return false; } - stdoutChannel.buffer.chop(available - readBytes); + channel->buffer.chop(available - readBytes); bool didRead = false; + bool isStdout = channel == &stdoutChannel; if (readBytes == 0) { - if (stdoutChannel.notifier) - stdoutChannel.notifier->setEnabled(false); - } else if (processChannel == QProcess::StandardOutput) { + if (channel->notifier) + channel->notifier->setEnabled(false); + } else if ((processChannel == QProcess::StandardOutput) == isStdout) { didRead = true; if (!emittedReadyRead) { emittedReadyRead = true; @@ -948,53 +950,27 @@ bool QProcessPrivate::_q_canReadStandardOutput() emittedReadyRead = false; } } - emit q->readyReadStandardOutput(QProcess::QPrivateSignal()); + if (isStdout) + emit q->readyReadStandardOutput(QProcess::QPrivateSignal()); + else + emit q->readyReadStandardError(QProcess::QPrivateSignal()); return didRead; } /*! \internal */ -bool QProcessPrivate::_q_canReadStandardError() +bool QProcessPrivate::_q_canReadStandardOutput() { - Q_Q(QProcess); - qint64 available = bytesAvailableFromStderr(); - if (available == 0) { - if (stderrChannel.notifier) - stderrChannel.notifier->setEnabled(false); - closeChannel(&stderrChannel); - return false; - } - - char *ptr = stderrChannel.buffer.reserve(available); - qint64 readBytes = readFromStderr(ptr, available); - if (readBytes == -1) { - processError = QProcess::ReadError; - q->setErrorString(QProcess::tr("Error reading from process")); - emit q->error(processError); - return false; - } - if (stderrChannel.closed) { - stderrChannel.buffer.chop(readBytes); - return false; - } - - stderrChannel.buffer.chop(available - readBytes); + return tryReadFromChannel(&stdoutChannel); +} - bool didRead = false; - if (readBytes == 0) { - if (stderrChannel.notifier) - stderrChannel.notifier->setEnabled(false); - } else if (processChannel == QProcess::StandardError) { - didRead = true; - if (!emittedReadyRead) { - emittedReadyRead = true; - emit q->readyRead(); - emittedReadyRead = false; - } - } - emit q->readyReadStandardError(QProcess::QPrivateSignal()); - return didRead; +/*! + \internal +*/ +bool QProcessPrivate::_q_canReadStandardError() +{ + return tryReadFromChannel(&stderrChannel); } /*! diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index c491c57abc..6cd9047c04 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -329,6 +329,7 @@ public: bool openChannel(Channel &channel); void closeChannel(Channel *channel); void closeWriteChannel(); + bool tryReadFromChannel(Channel *channel); // obviously, only stdout and stderr QString program; QStringList arguments; @@ -386,10 +387,8 @@ public: bool waitForFinished(int msecs = 30000); bool waitForWrite(int msecs = 30000); - qint64 bytesAvailableFromStdout() const; - qint64 bytesAvailableFromStderr() const; - qint64 readFromStdout(char *data, qint64 maxlen); - qint64 readFromStderr(char *data, qint64 maxlen); + qint64 bytesAvailableInChannel(const Channel *channel) const; + qint64 readFromChannel(const Channel *channel, char *data, qint64 maxlen); qint64 writeToStdin(const char *data, qint64 maxlen); void cleanup(); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 4147191f08..430393d6f2 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -963,45 +963,24 @@ bool QProcessPrivate::processStarted() return i <= 0; } -qint64 QProcessPrivate::bytesAvailableFromStdout() const +qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const { int nbytes = 0; qint64 available = 0; - if (::ioctl(stdoutChannel.pipe[0], FIONREAD, (char *) &nbytes) >= 0) + if (::ioctl(channel->pipe[0], FIONREAD, (char *) &nbytes) >= 0) available = (qint64) nbytes; #if defined (QPROCESS_DEBUG) - qDebug("QProcessPrivate::bytesAvailableFromStdout() == %lld", available); + qDebug("QProcessPrivate::bytesAvailableInChannel(%d) == %lld", channel - &stdinChannel, available); #endif return available; } -qint64 QProcessPrivate::bytesAvailableFromStderr() const +qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint64 maxlen) { - int nbytes = 0; - qint64 available = 0; - if (::ioctl(stderrChannel.pipe[0], FIONREAD, (char *) &nbytes) >= 0) - available = (qint64) nbytes; -#if defined (QPROCESS_DEBUG) - qDebug("QProcessPrivate::bytesAvailableFromStderr() == %lld", available); -#endif - return available; -} - -qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen) -{ - qint64 bytesRead = qt_safe_read(stdoutChannel.pipe[0], data, maxlen); -#if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::readFromStdout(%p \"%s\", %lld) == %lld", - data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead); -#endif - return bytesRead; -} - -qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen) -{ - qint64 bytesRead = qt_safe_read(stderrChannel.pipe[0], data, maxlen); + qint64 bytesRead = qt_safe_read(channel->pipe[0], data, maxlen); #if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::readFromStderr(%p \"%s\", %lld) == %lld", + qDebug("QProcessPrivate::readFromChannel(%d, %p \"%s\", %lld) == %lld", + channel - &stdinChannel, data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead); #endif return bytesRead; diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 61cf21751e..2dd4c475d8 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -564,47 +564,26 @@ bool QProcessPrivate::processStarted() return processState == QProcess::Running; } -qint64 QProcessPrivate::bytesAvailableFromStdout() const +qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const { - if (stdoutChannel.pipe[0] == INVALID_Q_PIPE) + if (channel->pipe[0] == INVALID_Q_PIPE) return 0; - if (!stdoutChannel.reader) + if (!channel->reader) return 0; - DWORD bytesAvail = stdoutChannel.reader->bytesAvailable(); + DWORD bytesAvail = channel->reader->bytesAvailable(); #if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::bytesAvailableFromStdout() == %d", bytesAvail); + qDebug("QProcessPrivate::bytesAvailableInChannel(%d) == %d", channel - &stdinChannel, bytesAvail); #endif return bytesAvail; } -qint64 QProcessPrivate::bytesAvailableFromStderr() const +qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint64 maxlen) { - if (stderrChannel.pipe[0] == INVALID_Q_PIPE) - return 0; - - if (!stderrChannel.reader) - return 0; - - DWORD bytesAvail = stderrChannel.reader->bytesAvailable(); -#if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::bytesAvailableFromStderr() == %d", bytesAvail); -#endif - return bytesAvail; + return channel->reader ? channel->reader->read(data, maxlen) : 0; } -qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen) -{ - return stdoutChannel.reader ? stdoutChannel.reader->read(data, maxlen) : 0; -} - -qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen) -{ - return stderrChannel.reader ? stderrChannel.reader->read(data, maxlen) : 0; -} - - static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId) { DWORD currentProcId = 0; @@ -740,14 +719,14 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) return true; // If we wouldn't write anything, check if we can read stdout. - if (bytesAvailableFromStdout() != 0) { - _q_canReadStandardOutput(); + if (bytesAvailableInChannel(&stdoutChannel) != 0) { + tryReadFromChannel(&stdoutChannel); timer.resetIncrements(); } // Check if we can read stderr. - if (bytesAvailableFromStderr() != 0) { - _q_canReadStandardError(); + if (bytesAvailableInChannel(&stderrChannel) != 0) { + tryReadFromChannel(&stderrChannel); timer.resetIncrements(); } diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp index b1c41ff069..e0bee48598 100644 --- a/src/corelib/io/qprocess_wince.cpp +++ b/src/corelib/io/qprocess_wince.cpp @@ -174,22 +174,12 @@ bool QProcessPrivate::processStarted() return processState == QProcess::Running; } -qint64 QProcessPrivate::bytesAvailableFromStdout() const +qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *) const { return 0; } -qint64 QProcessPrivate::bytesAvailableFromStderr() const -{ - return 0; -} - -qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen) -{ - return -1; -} - -qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen) +qint64 QProcessPrivate::readFromChannel(const Channel *, char *data, qint64 maxlen) { return -1; } -- cgit v1.2.3 From 6ca3ab626a04c3b05e6b3fde9a48457cf89c2889 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 17:15:03 -0700 Subject: Don't try to read from invalid file descriptors in QProcess strace reveals that we do ioctl(-1, FIONREAD) and get EBADF. The only case where this could happen is inside _q_processDied, which calls the read functions without checking if the pipe is still open. Change-Id: I67637fc4267be73fc03d40c444fdfea89e1ef715 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 3 +++ src/corelib/io/qprocess_unix.cpp | 2 ++ src/corelib/io/qprocess_win.cpp | 11 +++++------ 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 615e584f81..0436aa5428 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -903,6 +903,9 @@ void QProcessPrivate::cleanup() bool QProcessPrivate::tryReadFromChannel(Channel *channel) { Q_Q(QProcess); + if (channel->pipe[0] == INVALID_Q_PIPE) + return false; + qint64 available = bytesAvailableInChannel(channel); if (available == 0) { if (channel->notifier) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 430393d6f2..3c1eeb5f91 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -965,6 +965,7 @@ bool QProcessPrivate::processStarted() qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const { + Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE); int nbytes = 0; qint64 available = 0; if (::ioctl(channel->pipe[0], FIONREAD, (char *) &nbytes) >= 0) @@ -977,6 +978,7 @@ qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint64 maxlen) { + Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE); qint64 bytesRead = qt_safe_read(channel->pipe[0], data, maxlen); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::readFromChannel(%d, %p \"%s\", %lld) == %lld", diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 2dd4c475d8..7b3f1f8f58 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -566,11 +566,8 @@ bool QProcessPrivate::processStarted() qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const { - if (channel->pipe[0] == INVALID_Q_PIPE) - return 0; - - if (!channel->reader) - return 0; + Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE); + Q_ASSERT(channel->reader); DWORD bytesAvail = channel->reader->bytesAvailable(); #if defined QPROCESS_DEBUG @@ -581,7 +578,9 @@ qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint64 maxlen) { - return channel->reader ? channel->reader->read(data, maxlen) : 0; + Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE); + Q_ASSERT(channel->reader); + return channel->reader->read(data, maxlen); } static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId) -- cgit v1.2.3 From 3ccfc351fdcbb117e2872229382e45a929dac62a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 5 Jun 2014 16:44:07 -0700 Subject: QProcess: Handle spurious socket notifications for stdout and stderr On Unix systems where the GUI event dispatcher uses a notification system for socket notifiers that is out of band compared to select(), it's possible for the QSocketNotifier to activate after the pipe has been read from. When that happened, the ioctl(2) call with FIONREAD might return 0 bytes available, which we interpreted to mean EOF. Instead of doing that, always try to read at least one byte and examine the returned byte count from read(2). If it returns 0, that's a real EOF; if it returns -1 EWOULDBLOCK, we simply ignore the situation. That's the case on OS X: the Cocoa event dispatcher uses CFSocket to get notifications and those use kevent (and, apparently, an auxiliary thread) instead of an in-thread select() or poll(). That means the event loop would activate the QSocketNotifier even though there is nothing to be read. Task-number: QTBUG-39488 Change-Id: I1a58b5b1db7a47034fb36a78a005ebff96290efb Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 28 +++++++++++++++++++--------- src/corelib/io/qprocess_unix.cpp | 4 ++++ src/corelib/io/qwindowspipereader.cpp | 4 +++- 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 0436aa5428..b03e96d0f6 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -907,24 +908,33 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel) return false; qint64 available = bytesAvailableInChannel(channel); - if (available == 0) { - if (channel->notifier) - channel->notifier->setEnabled(false); - closeChannel(channel); -#if defined QPROCESS_DEBUG - qDebug("QProcessPrivate::tryReadFromChannel(%d), 0 bytes available", channel - &stdinChannel); -#endif - return false; - } + if (available == 0) + available = 1; // always try to read at least one byte char *ptr = channel->buffer.reserve(available); qint64 readBytes = readFromChannel(channel, ptr, available); + if (readBytes <= 0) + channel->buffer.chop(available); + if (readBytes == -2) { + // EWOULDBLOCK + return false; + } if (readBytes == -1) { processError = QProcess::ReadError; q->setErrorString(QProcess::tr("Error reading from process")); emit q->error(processError); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::tryReadFromChannel(%d), failed to read from the process", channel - &stdinChannel); +#endif + return false; + } + if (readBytes == 0) { + // EOF + if (channel->notifier) + channel->notifier->setEnabled(false); + closeChannel(channel); +#if defined QPROCESS_DEBUG + qDebug("QProcessPrivate::tryReadFromChannel(%d), 0 bytes available", channel - &stdinChannel); #endif return false; } diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 3c1eeb5f91..2269740a2f 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -981,10 +981,14 @@ qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE); qint64 bytesRead = qt_safe_read(channel->pipe[0], data, maxlen); #if defined QPROCESS_DEBUG + int save_errno = errno; qDebug("QProcessPrivate::readFromChannel(%d, %p \"%s\", %lld) == %lld", channel - &stdinChannel, data, qt_prettyDebug(data, bytesRead, 16).constData(), maxlen, bytesRead); + errno = save_errno; #endif + if (bytesRead == -1 && errno == EWOULDBLOCK) + return -2; return bytesRead; } diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 7dd2125e70..d8a3ec9b42 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -132,7 +132,7 @@ qint64 QWindowsPipeReader::bytesAvailable() const qint64 QWindowsPipeReader::read(char *data, qint64 maxlen) { if (pipeBroken && actualReadBufferSize == 0) - return -1; // signal EOF + return 0; // signal EOF qint64 readSoFar; // If startAsyncRead() has read data, copy it to its destination. @@ -159,6 +159,8 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen) emitReadyReadTimer->stop(); if (!readSequenceStarted) startAsyncRead(); + if (readSoFar == 0) + return -2; // signal EWOULDBLOCK } return readSoFar; -- cgit v1.2.3 From 000d98d826e7b85655456a66522812da338c3f72 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Jun 2014 00:27:55 +0200 Subject: Bump version Change-Id: I867c3b4aecc82095e65bd7f820e7fe6d14005705 --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 707e46dd40..d1aae1a681 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -45,11 +45,11 @@ #include -#define QT_VERSION_STR "5.3.1" +#define QT_VERSION_STR "5.3.2" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050301 +#define QT_VERSION 0x050302 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ -- cgit v1.2.3 From 2de8ef2e49d1a14b5d4acf7bfd9539dadbcbc54f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Jun 2014 15:38:35 -0700 Subject: Fix compilation with the Intel compiler on certain systems We require the intrinsics from immintrin.h, so include it unconditioanlly with that compiler. Change-Id: I4a17676631f9d89e2d22e486f40c9b177ca06c1e Reviewed-by: Olivier Goffart --- src/corelib/tools/qsimd_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index f4ca971567..e1c22bac71 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -139,8 +139,10 @@ || (defined(Q_CC_CLANG) && (__clang_major__ * 100 + __clang_minor__ >= 208)) \ || defined(Q_CC_INTEL)) # define QT_COMPILER_SUPPORTS_X86INTRIN -# ifndef Q_CC_INTEL +# ifdef Q_CC_INTEL // The Intel compiler has no -- all intrinsics are in ; +# include +# else // GCC 4.4 and Clang 2.8 added a few more intrinsics there # include # endif -- cgit v1.2.3 From feda990ae8fa3bc25ad5b5b7f7cc4733137519d6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 6 Jun 2014 14:26:26 +0200 Subject: QEventDispatcherWin32: Use a shared class name for the message window. Introduce a global-static struct storing atom and class name for the message window to be shared between threads. This prevents RegisterWindow()/UnregisterWindow() of different threads (using exec()) from interfering and silently failing. Task-number: QTBUG-39471 Change-Id: I9bc1106a41f64749c55825a96973921bb831458f Reviewed-by: Joerg Bornemann --- src/corelib/kernel/qeventdispatcher_win.cpp | 54 ++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 64ad2ff0d3..db2d30f2f5 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -325,8 +325,6 @@ QEventDispatcherWin32Private::~QEventDispatcherWin32Private() { if (internalHwnd) DestroyWindow(internalHwnd); - QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); - UnregisterClass((wchar_t*)className.utf16(), qWinAppInst()); } void QEventDispatcherWin32Private::activateEventNotifier(QWinEventNotifier * wen) @@ -486,10 +484,26 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) #endif } -static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) +// Provide class name and atom for the message window used by +// QEventDispatcherWin32Private via Q_GLOBAL_STATIC shared between threads. +struct QWindowsMessageWindowClassContext +{ + QWindowsMessageWindowClassContext(); + ~QWindowsMessageWindowClassContext(); + + ATOM atom; + wchar_t *className; +}; + +QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext() + : atom(0), className(0) { // make sure that multiple Qt's can coexist in the same process - QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); + const QString qClassName = QStringLiteral("QEventDispatcherWin32_Internal_Widget") + + QString::number(quintptr(qt_internal_proc)); + className = new wchar_t[qClassName.size() + 1]; + qClassName.toWCharArray(className); + className[qClassName.size()] = 0; WNDCLASS wc; wc.style = 0; @@ -501,16 +515,37 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch wc.hCursor = 0; wc.hbrBackground = 0; wc.lpszMenuName = NULL; - wc.lpszClassName = reinterpret_cast (className.utf16()); + wc.lpszClassName = className; + atom = RegisterClass(&wc); + if (!atom) { + qErrnoWarning("%s: RegisterClass() failed", Q_FUNC_INFO, qPrintable(qClassName)); + delete [] className; + className = 0; + } +} + +QWindowsMessageWindowClassContext::~QWindowsMessageWindowClassContext() +{ + if (className) { + UnregisterClass(className, qWinAppInst()); + delete [] className; + } +} + +Q_GLOBAL_STATIC(QWindowsMessageWindowClassContext, qWindowsMessageWindowClassContext) - RegisterClass(&wc); +static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) +{ + QWindowsMessageWindowClassContext *ctx = qWindowsMessageWindowClassContext(); + if (!ctx->atom) + return 0; #ifdef Q_OS_WINCE HWND parent = 0; #else HWND parent = HWND_MESSAGE; #endif - HWND wnd = CreateWindow(wc.lpszClassName, // classname - wc.lpszClassName, // window name + HWND wnd = CreateWindow(ctx->className, // classname + ctx->className, // window name 0, // style 0, 0, 0, 0, // geometry parent, // parent @@ -519,7 +554,8 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch 0); // windows creation data. if (!wnd) { - qWarning("QEventDispatcher: Failed to create QEventDispatcherWin32 internal window: %d\n", (int)GetLastError()); + qErrnoWarning("%s: CreateWindow() for QEventDispatcherWin32 internal window failed", Q_FUNC_INFO); + return 0; } #ifdef GWLP_USERDATA -- cgit v1.2.3 From 1a034ac218ee912b2f565a2fbafd7eb53ad6a3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 17 Jun 2014 15:10:03 +0200 Subject: Attempt to fix intel compiler build error. qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h(625): error #68: integer conversion resulted in a change of sign Task-number: QTBUG-39678 Change-Id: Ifb175bdcad820aa58cc0a1bcf6985a164376baf5 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobjectdefs_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index de6f65ab7d..de95fcc313 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -622,7 +622,7 @@ namespace QtPrivate { static char test(...); enum { Ok = sizeof(test(dummy())) == sizeof(int), - Value = Ok ? sizeof...(ArgList) : int(ComputeFunctorArgumentCountHelper, Ok>::Value) + Value = Ok ? int(sizeof...(ArgList)) : int(ComputeFunctorArgumentCountHelper, Ok>::Value) }; }; -- cgit v1.2.3 From d98004cd2f33e8147cff9f3cb203fdef5e6dd00e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 May 2014 18:32:32 +0200 Subject: fix QT_SUPPORTS macro with msvc2008 Change-Id: I70ffba51d2672574d7cefc3cb44724341cd86f22 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d1aae1a681..f610cfab8c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -59,7 +59,11 @@ #include #include #endif -#define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) +#if defined(Q_CC_MSVC) && _MSC_VER <= 1500 /* VS2008 */ +# define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE) +#else +# define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) +#endif #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define QT_NO_UNSHARABLE_CONTAINERS #endif -- cgit v1.2.3 From 884b38157689a893ace0a4c793fab921167abb2c Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 8 Jun 2014 21:46:24 +0200 Subject: Fix data race on QLoggingCategory when using qDebug from multiple threads setEnabled() would race with isEnabled()/isDebugEnabled()/etc. Change-Id: I2004cba81d5417a634b97f5c2f98d3a4ab71770d Reviewed-by: David Faure --- src/corelib/arch/qatomic_bootstrap.h | 4 +++- src/corelib/io/qloggingcategory.cpp | 36 ++++++++++++++++++++++++++---------- src/corelib/io/qloggingcategory.h | 35 +++++++++++++++++++++++++++-------- 3 files changed, 56 insertions(+), 19 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/arch/qatomic_bootstrap.h b/src/corelib/arch/qatomic_bootstrap.h index 7f17387c9c..0d6843a3e5 100644 --- a/src/corelib/arch/qatomic_bootstrap.h +++ b/src/corelib/arch/qatomic_bootstrap.h @@ -67,8 +67,10 @@ template struct QAtomicOps: QGenericAtomicOps > return --_q_value != 0; } - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW { + if (currentValue) + *currentValue = _q_value; if (_q_value == expectedValue) { _q_value = newValue; return true; diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 518052e537..45fab11939 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -50,6 +50,18 @@ const char qtDefaultCategoryName[] = "default"; Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory, (qtDefaultCategoryName)) +#ifndef Q_ATOMIC_INT8_IS_SUPPORTED +static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) +{ + const int bit = 1 << shift; + + if (enable) + atomic->fetchAndOrRelaxed(bit); + else + atomic->fetchAndAndRelaxed(~bit); +} +#endif + /*! \class QLoggingCategory \inmodule QtCore @@ -171,13 +183,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory, */ QLoggingCategory::QLoggingCategory(const char *category) : d(0), - name(0), - enabledDebug(true), - enabledWarning(true), - enabledCritical(true) + name(0) { Q_UNUSED(d); Q_UNUSED(placeholder); + enabled.store(0x01010101); // enabledDebug = enabledWarning = enabledCritical = true; const bool isDefaultCategory = (category == 0) || (strcmp(category, qtDefaultCategoryName) == 0); @@ -249,9 +259,9 @@ QLoggingCategory::~QLoggingCategory() bool QLoggingCategory::isEnabled(QtMsgType msgtype) const { switch (msgtype) { - case QtDebugMsg: return enabledDebug; - case QtWarningMsg: return enabledWarning; - case QtCriticalMsg: return enabledCritical; + case QtDebugMsg: return isDebugEnabled(); + case QtWarningMsg: return isWarningEnabled(); + case QtCriticalMsg: return isCriticalEnabled(); case QtFatalMsg: return true; } return false; @@ -270,9 +280,15 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const void QLoggingCategory::setEnabled(QtMsgType type, bool enable) { switch (type) { - case QtDebugMsg: enabledDebug = enable; break; - case QtWarningMsg: enabledWarning = enable; break; - case QtCriticalMsg: enabledCritical = enable; break; +#ifdef Q_ATOMIC_INT8_IS_SUPPORTED + case QtDebugMsg: bools.enabledDebug.store(enable); break; + case QtWarningMsg: bools.enabledWarning.store(enable); break; + case QtCriticalMsg: bools.enabledCritical.store(enable); break; +#else + case QtDebugMsg: setBoolLane(&enabled, enable, DebugShift); break; + case QtWarningMsg: setBoolLane(&enabled, enable, WarningShift); break; + case QtCriticalMsg: setBoolLane(&enabled, enable, CriticalShift); break; +#endif case QtFatalMsg: break; } } diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 4aec8e63bf..573af2105c 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -57,10 +57,15 @@ public: bool isEnabled(QtMsgType type) const; void setEnabled(QtMsgType type, bool enable); - bool isDebugEnabled() const { return enabledDebug; } - bool isWarningEnabled() const { return enabledWarning; } - bool isCriticalEnabled() const { return enabledCritical; } - +#ifdef Q_ATOMIC_INT8_IS_SUPPORTED + bool isDebugEnabled() const { return bools.enabledDebug.load(); } + bool isWarningEnabled() const { return bools.enabledWarning.load(); } + bool isCriticalEnabled() const { return bools.enabledCritical.load(); } +#else + bool isDebugEnabled() const { return enabled.load() >> DebugShift & 1; } + bool isWarningEnabled() const { return enabled.load() >> WarningShift & 1; } + bool isCriticalEnabled() const { return enabled.load() >> CriticalShift & 1; } +#endif const char *categoryName() const { return name; } // allows usage of both factory method and variable in qCX macros @@ -78,10 +83,24 @@ private: void *d; // reserved for future use const char *name; - bool enabledDebug; - bool enabledWarning; - bool enabledCritical; - bool placeholder[5]; // reserve for future use +#ifdef Q_BIG_ENDIAN + enum { DebugShift = 0, WarningShift = 8, CriticalShift = 16 }; +#else + enum { DebugShift = 24, WarningShift = 16, CriticalShift = 8 }; +#endif + + struct AtomicBools { +#ifdef Q_ATOMIC_INT8_IS_SUPPORTED + QBasicAtomicInteger enabledDebug; + QBasicAtomicInteger enabledWarning; + QBasicAtomicInteger enabledCritical; +#endif + }; + union { + AtomicBools bools; + QBasicAtomicInt enabled; + }; + bool placeholder[4]; // reserve for future use }; #define Q_DECLARE_LOGGING_CATEGORY(name) \ -- cgit v1.2.3 From 4a83ce611d91348903882eafe34c35f44bee1776 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Jun 2014 08:53:34 -0700 Subject: Move most of the QLibraryPrivate initialization to its constructor This commit moves the setting of the loadHints to inside the constructor or to QLibraryStore::findOrCreate (which is under a mutex). This avoids data race conditions with two threads asking for the same plugin at the same time, with different load hints. This also opportunistically moves the setting of the error message for empty file names. Task-number: QTBUG-39642 Change-Id: I497a41781d10e407d6420116a0b05fdfe2b548de Reviewed-by: David Faure --- src/corelib/plugin/qlibrary.cpp | 35 ++++++++++++++++++++++++++--------- src/corelib/plugin/qlibrary_p.h | 6 ++++-- src/corelib/plugin/qpluginloader.cpp | 7 ++----- 3 files changed, 32 insertions(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 9736950c89..50281b632a 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -359,7 +359,7 @@ class QLibraryStore { public: inline ~QLibraryStore(); - static inline QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version); + static inline QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version, QLibrary::LoadHints loadHints); static inline void releaseLibrary(QLibraryPrivate *lib); static inline void cleanup(); @@ -438,17 +438,21 @@ QLibraryStore *QLibraryStore::instance() return qt_library_data; } -inline QLibraryPrivate *QLibraryStore::findOrCreate(const QString &fileName, const QString &version) +inline QLibraryPrivate *QLibraryStore::findOrCreate(const QString &fileName, const QString &version, + QLibrary::LoadHints loadHints) { QMutexLocker locker(&qt_library_mutex); QLibraryStore *data = instance(); // check if this library is already loaded QLibraryPrivate *lib = 0; - if (Q_LIKELY(data)) + if (Q_LIKELY(data)) { lib = data->libraryMap.value(fileName); + if (lib) + lib->mergeLoadHints(loadHints); + } if (!lib) - lib = new QLibraryPrivate(fileName, version); + lib = new QLibraryPrivate(fileName, version, loadHints); // track this library if (Q_LIKELY(data)) @@ -479,21 +483,34 @@ inline void QLibraryStore::releaseLibrary(QLibraryPrivate *lib) delete lib; } -QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version) +QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints) : pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), - loadHints(0), + loadHints(loadHints), libraryRefCount(0), libraryUnloadCount(0), pluginState(MightBeAPlugin) -{ } +{ + if (canonicalFileName.isEmpty()) + errorString = QLibrary::tr("The shared library was not found."); +} -QLibraryPrivate *QLibraryPrivate::findOrCreate(const QString &fileName, const QString &version) +QLibraryPrivate *QLibraryPrivate::findOrCreate(const QString &fileName, const QString &version, + QLibrary::LoadHints loadHints) { - return QLibraryStore::findOrCreate(fileName, version); + return QLibraryStore::findOrCreate(fileName, version, loadHints); } QLibraryPrivate::~QLibraryPrivate() { } +void QLibraryPrivate::mergeLoadHints(QLibrary::LoadHints lh) +{ + // if the library is already loaded, we can't change the load hints + if (pHnd) + return; + + loadHints = lh; +} + QFunctionPointer QLibraryPrivate::resolve(const char *symbol) { if (!pHnd) diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 20b0c7e20f..e58d18e87b 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -94,7 +94,8 @@ public: void release(); QFunctionPointer resolve(const char *); - static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString()); + static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString(), + QLibrary::LoadHints loadHints = 0); static QStringList suffixes_sys(const QString &fullVersion); static QStringList prefixes_sys(); @@ -117,8 +118,9 @@ public: } private: - explicit QLibraryPrivate(const QString &canonicalFileName, const QString &version); + explicit QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints); ~QLibraryPrivate(); + void mergeLoadHints(QLibrary::LoadHints loadHints); bool load_sys(); bool unload_sys(); diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index e4a1d725ec..2c139669e6 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -352,11 +352,8 @@ void QPluginLoader::setFileName(const QString &fileName) else fn = locatePlugin(fileName); - d = QLibraryPrivate::findOrCreate(fn); - d->loadHints = lh; - if (fn.isEmpty()) - d->errorString = QLibrary::tr("The shared library was not found."); - else + d = QLibraryPrivate::findOrCreate(fn, QString(), lh); + if (!fn.isEmpty()) d->updatePluginState(); #else -- cgit v1.2.3 From 1e54f1316d30eae86bc38490f84aa55ee4568a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Fri, 20 Jun 2014 12:34:30 +0100 Subject: Print the reason why SetWindowsHookEx failed. Task-number: QTBUG-14301 Change-Id: I4733a57034259b013864bf91aba6cce2f411ab48 Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qeventdispatcher_win.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index db2d30f2f5..f38ac7bf26 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -656,7 +656,9 @@ void QEventDispatcherWin32::createInternalHwnd() // setup GetMessage hook needed to drive our posted events d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId()); if (!d->getMessageHook) { - qFatal("Qt: INTERNALL ERROR: failed to install GetMessage hook"); + int errorCode = GetLastError(); + qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s", + errorCode, qPrintable(qt_error_string(errorCode))); } #endif -- cgit v1.2.3 From cb68607feea2fec680a275a4d9c4070e9a97d85f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 17 Jun 2014 12:59:47 +0200 Subject: Fix memory leaks in QFseventsFileSystemWatcherEngine Sprinkle in some NSAutoReleasePools. Task-number: QTBUG-38637 Change-Id: I0cb42d9d1cbcc4e9d273d0d43e4925fc02885b66 Reviewed-by: Eike Ziller --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index 981d663694..085396da6d 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -64,6 +64,25 @@ QT_BEGIN_NAMESPACE +namespace { +class RaiiAutoreleasePool +{ + Q_DISABLE_COPY(RaiiAutoreleasePool) + +public: + RaiiAutoreleasePool() + : pool([[NSAutoreleasePool alloc] init]) + {} + + ~RaiiAutoreleasePool() + { [pool release]; } + +private: + NSAutoreleasePool *pool; +}; +#define Q_AUTORELEASE_POOL(pool) RaiiAutoreleasePool pool; Q_UNUSED(pool); +} + static void callBackFunction(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, @@ -71,6 +90,8 @@ static void callBackFunction(ConstFSEventStreamRef streamRef, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) { + Q_AUTORELEASE_POOL(pool) + char **paths = static_cast(eventPaths); QFseventsFileSystemWatcherEngine *engine = static_cast(clientCallBackInfo); engine->processEvent(streamRef, numEvents, paths, eventFlags, eventIds); @@ -283,6 +304,7 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString path void QFseventsFileSystemWatcherEngine::restartStream() { + Q_AUTORELEASE_POOL(pool) QMutexLocker locker(&lock); stopStream(); startStream(); @@ -313,6 +335,8 @@ QFseventsFileSystemWatcherEngine::QFseventsFileSystemWatcherEngine(QObject *pare QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine() { + Q_AUTORELEASE_POOL(pool) + if (stream) FSEventStreamStop(stream); @@ -327,6 +351,8 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories) { + Q_AUTORELEASE_POOL(pool) + if (stream) { DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream)); FSEventStreamFlushSync(stream); @@ -413,6 +439,8 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat QStringList *files, QStringList *directories) { + Q_AUTORELEASE_POOL(pool) + QMutexLocker locker(&lock); bool needsRestart = false; -- cgit v1.2.3 From 0e14a58a96fc3deb78ac152c480cac3ac907f0f7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 22 Jun 2014 10:46:10 +0200 Subject: Doc: qInstallMessageHandler cannot return 0. The commit 124044613dde9a9596312102ca377bc74ed08165 (in Nov 2011) changed that: the first call will return the builtin message handler, not 0. Change-Id: I535ad69639f2341f9b664a6e2e7b12802ae785e0 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- src/corelib/global/qlogging.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 4a602e4b2b..ff4372a049 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1443,8 +1443,7 @@ void qErrnoWarning(int code, const char *msg, ...) \since 5.0 Installs a Qt message \a handler which has been defined - previously. Returns a pointer to the previous message handler - (which may be 0). + previously. Returns a pointer to the previous message handler. The message handler is a function that prints out debug messages, warnings, critical and fatal error messages. The Qt library (debug -- cgit v1.2.3 From 00dce1cc0078f9633d121908172346cc22deb3c3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 23 Jun 2014 11:47:49 -0700 Subject: Make the fetchAndAddRelaxed function a member template This way, no compiler can instantiate it at class instantiation time. We don't want them to do it for T that are function pointers (sizeof functions is meaningless). Change-Id: I6d5044bd5d9ffd0d347f1f38ab33c64213730788 Reviewed-by: Olivier Goffart Reviewed-by: David Faure --- src/corelib/arch/qatomic_bootstrap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/arch/qatomic_bootstrap.h b/src/corelib/arch/qatomic_bootstrap.h index 0d6843a3e5..1ab901d826 100644 --- a/src/corelib/arch/qatomic_bootstrap.h +++ b/src/corelib/arch/qatomic_bootstrap.h @@ -85,8 +85,8 @@ template struct QAtomicOps: QGenericAtomicOps > return tmp; } - static - T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + template static + T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) Q_DECL_NOTHROW { T returnValue = _q_value; _q_value += valueToAdd; -- cgit v1.2.3 From 7cc893b2169555a8c4d8242f69e7ef12ebc36185 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Tue, 24 Jun 2014 08:41:11 +0300 Subject: Fix QRingBuffer::readPointerAtPosition() Fix condition to allow return a valid pointer when head != 0. Change-Id: I5215f7dfc44924016c2d9b67ab2d9935b5164d7a Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qringbuffer_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index b17c6d2f40..5d25b0add1 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -90,7 +90,7 @@ public: // special case: it is in the first buffer int nextDataBlockSizeValue = nextDataBlockSize(); - if (pos - head < nextDataBlockSizeValue) { + if (pos < nextDataBlockSizeValue) { length = nextDataBlockSizeValue - pos; return buffers.at(0).constData() + head + pos; } -- cgit v1.2.3 From 1f3d9b12ab427cf81cc0a38622a54bf4e8edac49 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 25 Jun 2014 09:47:56 +0200 Subject: Fix logging file location docs The location mentioned in the docs didn't work because it was wrong. Change-Id: I80bbc16bfecc5662317f9963299981266b95bba8 Reviewed-by: Kai Koehne --- src/corelib/io/qloggingcategory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 45fab11939..07245ddea2 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -141,13 +141,13 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) Order of evaluation: \list - \li Rules from QtProject/qlogging.ini + \li Rules from QtProject/qtlogging.ini \li Rules set by \l setFilterRules() \li Rules from file in \c QT_LOGGING_CONF \li Rules from environment variable QT_LOGGING_RULES \endlist - The \c QtProject/qlogging.ini file is looked up in all directories returned + The \c QtProject/qtlogging.ini file is looked up in all directories returned by QStandardPaths::GenericConfigLocation, e.g. \list -- cgit v1.2.3 From 1e303a286e0df7723ca0144539407192363cafe3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 12 Jun 2014 17:02:23 +0200 Subject: Mark behavior of QFileInfo::absoluteFilePath as undefined in corner cases The current description was misleading, since e.g. QFileInfo().absoluteFilePath() will always return an empty string. QFileInfo("").absoluteFilePath() however will return the current working directory ... Instead of documenting these small quirks we should rather mark the exact behavior as undefined, like we already do for absolutePath(). Change-Id: I70358413528429c2c2dee37480ad018aae26e6cb Reviewed-by: Oswald Buddenhagen Reviewed-by: Jerome Pasion --- src/corelib/io/qfileinfo.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 60f7e47e62..210bb3898c 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -530,7 +530,8 @@ void QFileInfo::setFile(const QDir &dir, const QString &file) is true. In contrast to canonicalFilePath(), symbolic links or redundant "." or ".." elements are not necessarily removed. - If the QFileInfo is empty it returns QDir::currentPath(). + \warning If filePath() is empty the behavior of this function + is undefined. \sa filePath(), canonicalFilePath(), isRelative() */ @@ -572,8 +573,8 @@ QString QFileInfo::canonicalFilePath() const In contrast to canonicalPath() symbolic links or redundant "." or ".." elements are not necessarily removed. - \warning If the QFileInfo object was created with an empty QString, - the behavior of this function is undefined. + \warning If filePath() is empty the behavior of this function + is undefined. \sa absoluteFilePath(), path(), canonicalPath(), fileName(), isRelative() */ -- cgit v1.2.3 From 4108bfb47c058c415c43bd838248fa738a086ebe Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 19 Jun 2014 12:37:48 +0200 Subject: WinRT: no read-only paths in QStandardpaths::writableLocation As FontsLocation, HomeLocation and RuntimeLocation are read- only on WinRT WritableLocation should return empty strings in these cases. In addition all the other options were added to the switch statement in writableLocation. Task-number: QTBUG-38581 Change-Id: Iab994556844e713c6fa02028a0ec824ecb5ee82b Reviewed-by: Andrew Knight --- src/corelib/io/qstandardpaths_winrt.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp index 84a3930ee0..feafdf2e7c 100644 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ b/src/corelib/io/qstandardpaths_winrt.cpp @@ -103,14 +103,23 @@ QString QStandardPaths::writableLocation(StandardLocation type) case GenericCacheLocation: return writableLocation(GenericDataLocation) + QLatin1String("/cache"); - case RuntimeLocation: - case HomeLocation: - result = QDir::homePath(); - break; - case TempLocation: result = QDir::tempPath(); break; + + case ApplicationsLocation: + case DesktopLocation: + case FontsLocation: + case HomeLocation: + case RuntimeLocation: + // these are read-only + break; + + case DocumentsLocation: + case MusicLocation: + case MoviesLocation: + case PicturesLocation: + case DownloadLocation: default: Q_UNIMPLEMENTED(); } -- cgit v1.2.3 From 321d6dda759841a16a4e21d7e3bbbfc89504bee4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 26 Jun 2014 12:46:57 +0200 Subject: Fix QMutex documentation saying some function are static while they are not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qdoc only see a fake QMutex class (the same as the one built in bootstrap) But that fake QMutex had static member while the normal QMutex class has non static member. QMutexLocker::mutex is also a const function in the real QMutexLocker Task-number: QTBUG-38522 Change-Id: I220434ffc6a9e990029f770e2536ecb55b4e2182 Reviewed-by: Martin Smith Reviewed-by: Jędrzej Nowacki --- src/corelib/thread/qmutex.cpp | 2 +- src/corelib/thread/qmutex.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index fe5beb1c01..5e3f3a1cab 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -380,7 +380,7 @@ bool QBasicMutex::isRecursive() */ /*! - \fn QMutex *QMutexLocker::mutex() + \fn QMutex *QMutexLocker::mutex() const Returns the mutex on which the QMutexLocker is operating. diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 0ecc96a9b1..333865014b 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -186,10 +186,10 @@ public: inline explicit QMutex(RecursionMode mode = NonRecursive) { Q_UNUSED(mode); } - static inline void lock() {} - static inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; } - static inline void unlock() {} - static inline bool isRecursive() { return true; } + inline void lock() {} + inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; } + inline void unlock() {} + inline bool isRecursive() { return true; } private: Q_DISABLE_COPY(QMutex) @@ -201,9 +201,9 @@ public: inline explicit QMutexLocker(QMutex *) {} inline ~QMutexLocker() {} - static inline void unlock() {} - static void relock() {} - static inline QMutex *mutex() { return 0; } + inline void unlock() {} + void relock() {} + inline QMutex *mutex() const { return 0; } private: Q_DISABLE_COPY(QMutexLocker) -- cgit v1.2.3 From 6303307692c4ebdc3836f44da917d6b83ab3d4cc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 26 Jun 2014 12:54:33 +0200 Subject: Add a comment stating QMutex::isRecursive should be made const in Qt6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I452b0764790112c59af77bc8d95f403ff37cbc4a Reviewed-by: Jędrzej Nowacki --- src/corelib/thread/qmutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 333865014b..011555f904 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -77,7 +77,7 @@ public: return fastTryLock(); } - bool isRecursive(); + bool isRecursive(); //### Qt6: mark const private: inline bool fastTryLock() Q_DECL_NOTHROW { -- cgit v1.2.3 From 86fa23b5e35041189d8598945a642904b18dbedb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 28 Jun 2014 13:06:08 -0700 Subject: Don't compare the target methods for SlotObject connections When a new-style connection is created (a SlotObject), we don't store the method offset since there isn't one. So don't try to read it. Qt::UniqueConnection only applies to old-style connections, since we can't compare the slot objects for equality. In any case, an old-style connection and a new style will never be considered equal. Task-number: QTBUG-39927 Change-Id: I10a39a7bc97a2ec9509a0708038cc491bcc67329 Reviewed-by: Olivier Goffart Reviewed-by: Elias Probst --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 38e55b7aa9..5e8a97cdc0 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3230,7 +3230,7 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, int method_index_absolute = method_index + method_offset; while (c2) { - if (c2->receiver == receiver && c2->method() == method_index_absolute) + if (!c2->isSlotObject && c2->receiver == receiver && c2->method() == method_index_absolute) return 0; c2 = c2->nextConnectionList; } -- cgit v1.2.3 From 32514298131f7e8009a7641e20ff37be91cf4582 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Mon, 30 Jun 2014 13:52:25 +0200 Subject: Doc: Fix typo in QScopedValueRollback Change-Id: I9835b284d6bba5f7632cae6b179c6c1b08265e5c Reviewed-by: Friedemann Kleint --- src/corelib/tools/qscopedvaluerollback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qscopedvaluerollback.cpp b/src/corelib/tools/qscopedvaluerollback.cpp index 3201a3c87a..2d61d2114e 100644 --- a/src/corelib/tools/qscopedvaluerollback.cpp +++ b/src/corelib/tools/qscopedvaluerollback.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE \since 4.8 \ingroup misc - The QScopedAssignment class can be used to revert state when an + The QScopedValueRollback class can be used to revert state when an exception is thrown without needing to write try-catch blocks. It can also be used to manage variables that are temporarily set, -- cgit v1.2.3