From 6f75c189e1e5651b716afb316c801d080001c155 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 24 Feb 2016 12:36:36 +0100 Subject: Fix crash in QProcess::waitForFinished on Windows Suppose the user connects QProcess::readyReadStandardOutput with a slot that calls QCoreApplication::processEvents. Assume the event loop did not handle events between QProcess::start and QProcess::waitForFinished. The process writes to stdout and exits. QProcessPrivate::waitForFinished calls drainOutputPipes which calls QWindowsPipeWriter::waitForReadyRead. This in turn will trigger _q_processDied via the readyRead signal and processEvents. _q_processDied will delete the pid object and set pid to null. After drainOutputPipes returns, _q_processDied is called again but it must not be called if pid is already destroyed. Prevent calling _q_processDied if pid is null. Task-number: QTBUG-48697 Change-Id: Iee047938ee1529057a1a43d71f4e882750903c7e Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_win.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 80e6d5bb61..98ada82446 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -647,7 +647,8 @@ bool QProcessPrivate::waitForReadyRead(int msecs) return false; if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) { bool readyReadEmitted = drainOutputPipes(); - _q_processDied(); + if (pid) + _q_processDied(); return readyReadEmitted; } @@ -752,7 +753,8 @@ bool QProcessPrivate::waitForFinished(int msecs) if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) { drainOutputPipes(); - _q_processDied(); + if (pid) + _q_processDied(); return true; } -- cgit v1.2.3 From acba844c6ba0d72c6f37d8cbee8b343c23b05de1 Mon Sep 17 00:00:00 2001 From: David Weisgerber Date: Mon, 29 Feb 2016 15:48:47 +0100 Subject: Fixed reading REG_SZ without terminating \0 delivers garbage When reading from the registry, sometimes the string is not null terminated. In order to fix this, the preallocated QByteArray size is increased, so that there are guaranteed enough terminating \0 [Windows] Not null terminated strings are now read properly from the registry Change-Id: I95fdf42cbbb7074fcf010dd14d0241f02d3c412b Task-number: QTBUG-51382 Reviewed-by: Friedemann Kleint --- src/corelib/io/qsettings_win.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 1546219c3b..da0c4c3c14 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -484,6 +484,12 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa return false; } + // workaround for rare cases where trailing '\0' are missing in registry + if (dataType == REG_SZ || dataType == REG_EXPAND_SZ) + dataSize += 2; + else if (dataType == REG_MULTI_SZ) + dataSize += 4; + // get the value QByteArray data(dataSize, 0); res = RegQueryValueEx(handle, reinterpret_cast(rSubkeyName.utf16()), 0, 0, -- cgit v1.2.3 From 9a999eb7b09b5ddf1545546b9e71b0326c0bb0d2 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 26 Feb 2016 15:42:51 +0100 Subject: Remove QT_MOC_COMPAT from deprecated QProcess::error signal QT_MOC_COMPAT has the unfortunate behavior that it generates a warning at runtime, which also cannot be disabled. This is too draconic. Task-number: QTBUG-51517 Change-Id: I80af8b8b482671e4c9567281c3b1c504d737e202 Reviewed-by: hjk Reviewed-by: Eike Ziller Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index f95358250e..60c513d12e 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -243,7 +243,7 @@ Q_SIGNALS: void finished(int exitCode); // ### Qt 6: merge the two signals with a default value void finished(int exitCode, QProcess::ExitStatus exitStatus); #if QT_DEPRECATED_SINCE(5,6) - QT_MOC_COMPAT void error(QProcess::ProcessError error); + void error(QProcess::ProcessError error); #endif void errorOccurred(QProcess::ProcessError error); void stateChanged(QProcess::ProcessState state, QPrivateSignal); -- cgit v1.2.3 From f2bd0d119200d5b66069725563f7f12952e66da8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 3 Mar 2016 15:17:01 +0100 Subject: Clean up WINVER, _WIN32_WINNT macros for MinGW. Define WINVER, _WIN32_WINNT as 0x501 (Windows XP) in qt_windows.h. Remove definitions of the same/lower versions and unneeded definitions in other places. Remove definition for Borland compiler. Task-number: QTBUG-51673 Change-Id: I2a344a7f7cf78b2afbf45dcdf8bf2a19b93f0a07 Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qfilesystemiterator_win.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index d7fed87222..b00a56785e 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -31,13 +31,6 @@ ** ****************************************************************************/ -#if !defined(WINAPI_FAMILY) -# if _WIN32_WINNT < 0x0500 -# undef _WIN32_WINNT -# define _WIN32_WINNT 0x0500 -# endif // _WIN32_WINNT < 0x500 -#endif // !WINAPI_FAMILY - #include "qfilesystemiterator_p.h" #include "qfilesystemengine_p.h" #include "qplatformdefs.h" -- cgit v1.2.3 From d0b54cede8d8ea0b8431c64abb51d0cd1a71327b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 27 Nov 2015 13:28:45 +0100 Subject: Ensure QTextStream doesn't modify the Text flag on the underlying iodevice An empty read or a failed write on the underlying QIODevice of the text stream would lead to an early return where we wouldn't correctly restore the QIODevice::Text flag of the io device. Change-Id: I5b632f45dea6ede3f408113556c3dad1b96574e2 Task-number: QTBUG-47176 Reviewed-by: Marc Mutz Reviewed-by: Simon Hausmann --- src/corelib/io/qtextstream.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index a8fd2dd7ab..78dcbfe0e7 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -449,6 +449,10 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) bytesRead = device->read(buf, sizeof(buf)); } + // reset the Text flag. + if (textModeEnabled) + device->setTextModeEnabled(true); + if (bytesRead <= 0) return false; @@ -484,10 +488,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) readBuffer += QString::fromLatin1(buf, bytesRead); #endif - // reset the Text flag. - if (textModeEnabled) - device->setTextModeEnabled(true); - // remove all '\r\n' in the string. if (readBuffer.size() > oldReadBufferSize && textModeEnabled) { QChar CR = QLatin1Char('\r'); @@ -586,17 +586,18 @@ void QTextStreamPrivate::flushWriteBuffer() qDebug("QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d", qt_prettyDebug(data.constData(), qMin(data.size(),32), data.size()).constData(), int(bytesWritten)); #endif - if (bytesWritten <= 0) { - status = QTextStream::WriteFailed; - return; - } #if defined (Q_OS_WIN) - // replace the text flag + // reset the text flag if (textModeEnabled) device->setTextModeEnabled(true); #endif + if (bytesWritten <= 0) { + status = QTextStream::WriteFailed; + return; + } + // flush the file #ifndef QT_NO_QOBJECT QFileDevice *file = qobject_cast(device); -- cgit v1.2.3