Merge integration refs/builds/qtci/dev/1618515869

This commit is contained in:
Qt CI Bot 2021-04-16 10:08:31 +00:00
commit 7e15d57eb4
9 changed files with 59 additions and 33 deletions

View File

@ -294,6 +294,9 @@ public:
// private slots
bool _q_canReadStandardOutput();
bool _q_canReadStandardError();
#ifdef Q_OS_WIN
void _q_bytesWritten(qint64 bytes);
#endif
bool _q_canWrite();
bool _q_startupNotification();
void _q_processDied();

View File

@ -49,6 +49,7 @@
#include <qfileinfo.h>
#include <qrandom.h>
#include <qwineventnotifier.h>
#include <qscopedvaluerollback.h>
#include <private/qsystemlibrary_p.h>
#include <private/qthread_p.h>
#include <qdebug.h>
@ -832,16 +833,25 @@ qint64 QProcessPrivate::pipeWriterBytesToWrite() const
return stdinChannel.writer ? stdinChannel.writer->bytesToWrite() : qint64(0);
}
void QProcessPrivate::_q_bytesWritten(qint64 bytes)
{
Q_Q(QProcess);
if (!emittedBytesWritten) {
QScopedValueRollback<bool> guard(emittedBytesWritten, true);
emit q->bytesWritten(bytes);
}
_q_canWrite();
}
bool QProcessPrivate::writeToStdin()
{
Q_Q(QProcess);
if (!stdinChannel.writer) {
stdinChannel.writer = new QWindowsPipeWriter(stdinChannel.pipe[1], q);
QObject::connect(stdinChannel.writer, &QWindowsPipeWriter::bytesWritten,
q, &QProcess::bytesWritten);
QObjectPrivate::connect(stdinChannel.writer, &QWindowsPipeWriter::canWrite,
this, &QProcessPrivate::_q_canWrite);
QObjectPrivate::connect(stdinChannel.writer, &QWindowsPipeWriter::bytesWritten,
this, &QProcessPrivate::_q_bytesWritten);
} else {
if (stdinChannel.writer->isWriteOperationActive())
return true;

View File

@ -39,7 +39,6 @@
****************************************************************************/
#include "qwindowspipereader_p.h"
#include <qscopedvaluerollback.h>
#include <qcoreapplication.h>
#include <QMutexLocker>
@ -61,8 +60,7 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
readSequenceStarted(false),
pipeBroken(false),
readyReadPending(false),
winEventActPosted(false),
inReadyRead(false)
winEventActPosted(false)
{
ZeroMemory(&overlapped, sizeof(OVERLAPPED));
overlapped.hEvent = eventHandle;
@ -424,10 +422,8 @@ bool QWindowsPipeReader::consumePendingAndEmit(bool allowWinActPosting)
if (state != Running)
return false;
if (emitReadyRead && !inReadyRead) {
QScopedValueRollback<bool> guard(inReadyRead, true);
if (emitReadyRead)
emit readyRead();
}
if (emitPipeClosed) {
if (dwError != ERROR_BROKEN_PIPE && dwError != ERROR_PIPE_NOT_CONNECTED)
emit winError(dwError, QLatin1String("QWindowsPipeReader::consumePendingAndEmit"));
@ -484,8 +480,7 @@ bool QWindowsPipeReader::waitForNotification(const QDeadlineTimer &deadline)
/*!
Waits for the completion of the asynchronous read operation.
Returns \c true, if we've emitted the readyRead signal (non-recursive case)
or readyRead will be emitted by the event loop (recursive case).
Returns \c true, if we've emitted the readyRead signal.
*/
bool QWindowsPipeReader::waitForReadyRead(int msecs)
{

View File

@ -125,7 +125,6 @@ private:
bool pipeBroken;
bool readyReadPending;
bool winEventActPosted;
bool inReadyRead;
};
QT_END_NAMESPACE

View File

@ -39,7 +39,6 @@
****************************************************************************/
#include "qwindowspipewriter_p.h"
#include <qscopedvaluerollback.h>
#include <qcoreapplication.h>
#include <QMutexLocker>
@ -56,8 +55,7 @@ QWindowsPipeWriter::QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent)
stopped(true),
writeSequenceStarted(false),
bytesWrittenPending(false),
winEventActPosted(false),
inBytesWritten(false)
winEventActPosted(false)
{
ZeroMemory(&overlapped, sizeof(OVERLAPPED));
overlapped.hEvent = eventHandle;
@ -290,12 +288,7 @@ bool QWindowsPipeWriter::consumePendingAndEmit(bool allowWinActPosting)
if (stopped)
return false;
emit canWrite();
if (!inBytesWritten) {
QScopedValueRollback<bool> guard(inBytesWritten, true);
emit bytesWritten(numberOfBytesWritten);
}
emit bytesWritten(numberOfBytesWritten);
return true;
}
@ -317,8 +310,7 @@ bool QWindowsPipeWriter::waitForNotification(const QDeadlineTimer &deadline)
/*!
Waits for the completion of the asynchronous write operation.
Returns \c true, if we've emitted the bytesWritten signal (non-recursive case)
or bytesWritten will be emitted by the event loop (recursive case).
Returns \c true, if we've emitted the bytesWritten signal.
*/
bool QWindowsPipeWriter::waitForWrite(int msecs)
{

View File

@ -77,7 +77,6 @@ public:
HANDLE syncEvent() const { return syncHandle; }
Q_SIGNALS:
void canWrite();
void bytesWritten(qint64 bytes);
protected:
@ -104,7 +103,6 @@ private:
bool writeSequenceStarted;
bool bytesWrittenPending;
bool winEventActPosted;
bool inBytesWritten;
};
QT_END_NAMESPACE

View File

@ -133,6 +133,8 @@ public:
#elif defined(Q_OS_WIN)
~QLocalSocketPrivate();
void destroyPipeHandles();
void _q_canRead();
void _q_bytesWritten(qint64 bytes);
void _q_canWrite();
void _q_pipeClosed();
void _q_winError(ulong windowsError, const QString &function);
@ -161,6 +163,10 @@ public:
QLocalSocket::LocalSocketState state;
QString serverName;
QString fullServerName;
#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
bool emittedReadyRead;
bool emittedBytesWritten;
#endif
Q_OBJECT_BINDABLE_PROPERTY(QLocalSocketPrivate, QLocalSocket::SocketOptions, socketOptions)
};

View File

@ -38,6 +38,7 @@
****************************************************************************/
#include "qlocalsocket_p.h"
#include <qscopedvaluerollback.h>
QT_BEGIN_NAMESPACE
@ -45,7 +46,8 @@ void QLocalSocketPrivate::init()
{
Q_Q(QLocalSocket);
pipeReader = new QWindowsPipeReader(q);
q->connect(pipeReader, SIGNAL(readyRead()), SIGNAL(readyRead()));
QObjectPrivate::connect(pipeReader, &QWindowsPipeReader::readyRead,
this, &QLocalSocketPrivate::_q_canRead);
q->connect(pipeReader, SIGNAL(pipeClosed()), SLOT(_q_pipeClosed()), Qt::QueuedConnection);
q->connect(pipeReader, SIGNAL(winError(ulong,QString)), SLOT(_q_winError(ulong,QString)));
}
@ -99,7 +101,9 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
pipeWriter(0),
pipeReader(0),
error(QLocalSocket::UnknownSocketError),
state(QLocalSocket::UnconnectedState)
state(QLocalSocket::UnconnectedState),
emittedReadyRead(false),
emittedBytesWritten(false)
{
writeBufferChunkSize = QIODEVICE_BUFFERSIZE;
}
@ -223,10 +227,8 @@ qint64 QLocalSocket::writeData(const char *data, qint64 len)
d->write(data, len);
if (!d->pipeWriter) {
d->pipeWriter = new QWindowsPipeWriter(d->handle, this);
connect(d->pipeWriter, &QWindowsPipeWriter::bytesWritten,
this, &QLocalSocket::bytesWritten);
QObjectPrivate::connect(d->pipeWriter, &QWindowsPipeWriter::canWrite,
d, &QLocalSocketPrivate::_q_canWrite);
QObjectPrivate::connect(d->pipeWriter, &QWindowsPipeWriter::bytesWritten,
d, &QLocalSocketPrivate::_q_bytesWritten);
}
d->_q_canWrite();
return len;
@ -242,6 +244,15 @@ void QLocalSocket::abort()
close();
}
void QLocalSocketPrivate::_q_canRead()
{
Q_Q(QLocalSocket);
if (!emittedReadyRead) {
QScopedValueRollback<bool> guard(emittedReadyRead, true);
emit q->readyRead();
}
}
void QLocalSocketPrivate::_q_pipeClosed()
{
Q_Q(QLocalSocket);
@ -359,6 +370,16 @@ bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
return true;
}
void QLocalSocketPrivate::_q_bytesWritten(qint64 bytes)
{
Q_Q(QLocalSocket);
if (!emittedBytesWritten) {
QScopedValueRollback<bool> guard(emittedBytesWritten, true);
emit q->bytesWritten(bytes);
}
_q_canWrite();
}
void QLocalSocketPrivate::_q_canWrite()
{
Q_Q(QLocalSocket);

View File

@ -1294,7 +1294,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
QVERIFY(process.waitForFinished(5000));
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
QVERIFY(process.bytesAvailable() > bytesAvailable);
QVERIFY(process.bytesAvailable() >= bytesAvailable);
}
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
@ -1304,6 +1304,8 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
bytesAvailable = process->bytesAvailable();
process->write("bar", 4);
QVERIFY(process->waitForReadyRead(5000));
QVERIFY(process->bytesAvailable() > bytesAvailable);
bytesAvailable = process->bytesAvailable();
QTestEventLoop::instance().exitLoop();
}