QNetworkReplyFileImpl: Don't emit 'finished' in the ctor
Fixes: QTBUG-105618 Change-Id: I3bd36fbd5818d54088098e750643c3e2de30496e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 68f641095c5403925e49954aea0e65c4574121e0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
7bb095f09c
commit
f2c00dd038
@ -57,9 +57,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
|
||||
// we handle only local files
|
||||
QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
|
||||
setError(QNetworkReply::ProtocolInvalidOperationError, msg);
|
||||
setFinished(true); // We're finished, will emit finished() after ctor is done.
|
||||
QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
|
||||
Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
|
||||
fileOpenFinished(false);
|
||||
QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -260,6 +260,7 @@ private Q_SLOTS:
|
||||
void ioGetFromFileSpecial();
|
||||
void ioGetFromFile_data();
|
||||
void ioGetFromFile();
|
||||
void ioGetFromFileUrl();
|
||||
void ioGetFromFtp_data();
|
||||
void ioGetFromFtp();
|
||||
void ioGetFromFtpWithReuse();
|
||||
@ -3330,6 +3331,18 @@ void tst_QNetworkReply::ioGetFromFile()
|
||||
QCOMPARE(reader.data, data);
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::ioGetFromFileUrl()
|
||||
{
|
||||
// This immediately fails on non-windows platforms:
|
||||
QNetworkRequest request(QUrl("file://unc-server/some/path"));
|
||||
QNetworkReplyPtr reply(manager.get(request));
|
||||
QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
|
||||
// QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
|
||||
// was emitted before the constructor finished, leaving no chance at all to connect to the
|
||||
// signal
|
||||
QVERIFY(finishedSpy.wait());
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::ioGetFromFtp_data()
|
||||
{
|
||||
if (!ftpSupported)
|
||||
|
Loading…
x
Reference in New Issue
Block a user