summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qbytedata_p.h2
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp7
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp3
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp75
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h5
-rw-r--r--src/xmlpatterns/schema/qxsdschemaresolver.cpp9
-rw-r--r--tests/auto/xmlpatternsvalidator/files/complex-type-including-anonymous-type.xsd24
-rw-r--r--tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp13
8 files changed, 104 insertions, 34 deletions
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h
index 9aad6a9..17a3a60 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/tools/qbytedata_p.h
@@ -84,7 +84,7 @@ public:
}
- inline void append(QByteArray& bd)
+ inline void append(const QByteArray& bd)
{
if (bd.isEmpty())
return;
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index f1c51bc..22dd5cb 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -317,6 +317,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
return;
}
+ // only run when the QHttpNetworkConnection is not currently being destructed, e.g.
+ // this function is called from _q_disconnected which is called because
+ // of ~QHttpNetworkConnectionPrivate
+ if (!qobject_cast<QHttpNetworkConnection*>(connection)) {
+ return;
+ }
+
qint64 bytes = 0;
QAbstractSocket::SocketState socketState = socket->state();
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index af971a7..ba26dad 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -680,8 +680,7 @@ void QNetworkAccessHttpBackend::readFromHttp()
QByteDataBuffer list;
while (httpReply->bytesAvailable() != 0 && nextDownstreamBlockSize() != 0 && nextDownstreamBlockSize() > list.byteAmount()) {
- QByteArray data = httpReply->readAny();
- list.append(data);
+ list.append(httpReply->readAny());
}
if (!list.isEmpty())
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 320b1ac..0f5bdd0 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -403,6 +403,37 @@ qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const
return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount());
}
+void QNetworkReplyImplPrivate::initCacheSaveDevice()
+{
+ Q_Q(QNetworkReplyImpl);
+
+ // save the meta data
+ QNetworkCacheMetaData metaData;
+ metaData.setUrl(url);
+ metaData = backend->fetchCacheMetaData(metaData);
+
+ // save the redirect request also in the cache
+ QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirectionTarget.isValid()) {
+ QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes();
+ attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget);
+ metaData.setAttributes(attributes);
+ }
+
+ cacheSaveDevice = networkCache()->prepare(metaData);
+
+ if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
+ if (cacheSaveDevice && !cacheSaveDevice->isOpen())
+ qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
+ "class %s probably needs to be fixed",
+ networkCache()->metaObject()->className());
+
+ networkCache()->remove(url);
+ cacheSaveDevice = 0;
+ cacheEnabled = false;
+ }
+}
+
// we received downstream data and send this to the cache
// and to our readBuffer (which in turn gets read by the user of QNetworkReply)
void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
@@ -412,36 +443,12 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
return;
if (cacheEnabled && !cacheSaveDevice) {
- // save the meta data
- QNetworkCacheMetaData metaData;
- metaData.setUrl(url);
- metaData = backend->fetchCacheMetaData(metaData);
-
- // save the redirect request also in the cache
- QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirectionTarget.isValid()) {
- QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes();
- attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget);
- metaData.setAttributes(attributes);
- }
-
- cacheSaveDevice = networkCache()->prepare(metaData);
-
- if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
- if (cacheSaveDevice && !cacheSaveDevice->isOpen())
- qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
- "class %s probably needs to be fixed",
- networkCache()->metaObject()->className());
-
- networkCache()->remove(url);
- cacheSaveDevice = 0;
- cacheEnabled = false;
- }
+ initCacheSaveDevice();
}
qint64 bytesWritten = 0;
for (int i = 0; i < data.bufferCount(); i++) {
- QByteArray item = data[i];
+ QByteArray const &item = data[i];
if (cacheSaveDevice)
cacheSaveDevice->write(item.constData(), item.size());
@@ -454,6 +461,13 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
bytesDownloaded += bytesWritten;
lastBytesDownloaded = bytesDownloaded;
+ appendDownstreamDataSignalEmissions();
+}
+
+void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()
+{
+ Q_Q(QNetworkReplyImpl);
+
QPointer<QNetworkReplyImpl> qq = q;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
@@ -495,6 +509,15 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
_q_copyReadyRead();
}
+void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data)
+{
+ // TODO implement
+
+ // TODO call
+
+ qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented");
+}
+
void QNetworkReplyImplPrivate::finished()
{
Q_Q(QNetworkReplyImpl);
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 168e5cf..a7a568a 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -145,8 +145,13 @@ public:
void consume(qint64 count);
void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal);
qint64 nextDownstreamBlockSize() const;
+
+ void initCacheSaveDevice();
+ void appendDownstreamDataSignalEmissions();
void appendDownstreamData(QByteDataBuffer &data);
void appendDownstreamData(QIODevice *data);
+ void appendDownstreamData(const QByteArray &data);
+
void finished();
void error(QNetworkReply::NetworkError code, const QString &errorString);
void metaDataChanged();
diff --git a/src/xmlpatterns/schema/qxsdschemaresolver.cpp b/src/xmlpatterns/schema/qxsdschemaresolver.cpp
index 34eb12c..f3d1ed0 100644
--- a/src/xmlpatterns/schema/qxsdschemaresolver.cpp
+++ b/src/xmlpatterns/schema/qxsdschemaresolver.cpp
@@ -632,7 +632,14 @@ void XsdSchemaResolver::resolveSimpleContentComplexTypes(const XsdComplexType::P
} else {
// 1.2
const XsdSimpleType::Ptr anonType(new XsdSimpleType());
- anonType->setCategory(complexBaseType->contentType()->simpleType()->category());
+ XsdSimpleType::TypeCategory baseCategory = complexBaseType->contentType()->simpleType()->category();
+ anonType->setCategory(baseCategory);
+
+ if (baseCategory == XsdSimpleType::SimpleTypeList) {
+ const XsdSimpleType::Ptr baseSimpleType = complexBaseType->contentType()->simpleType();
+ anonType->setItemType(baseSimpleType->itemType());
+ }
+
anonType->setDerivationMethod(XsdSimpleType::DerivationRestriction);
anonType->setWxsSuperType(complexBaseType->contentType()->simpleType());
anonType->setFacets(complexTypeFacets(complexType));
diff --git a/tests/auto/xmlpatternsvalidator/files/complex-type-including-anonymous-type.xsd b/tests/auto/xmlpatternsvalidator/files/complex-type-including-anonymous-type.xsd
new file mode 100644
index 0000000..da765b4
--- /dev/null
+++ b/tests/auto/xmlpatternsvalidator/files/complex-type-including-anonymous-type.xsd
@@ -0,0 +1,24 @@
+<schema targetNamespace="http://qt.nokia.com/test"
+ xmlns:gml="http://qt.nokia.com/test"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <!-- ============= This is an excerpt from GML (http://www.opengis.net/gml)
+ which used to produce a crash in QXmlSchema ========== -->
+
+ <simpleType name="doubleList">
+ <list itemType="double"/>
+ </simpleType>
+
+ <complexType name="DirectPositionType">
+ <simpleContent>
+ <extension base="gml:doubleList"/>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="VectorType">
+ <simpleContent>
+ <restriction base="gml:DirectPositionType"/>
+ </simpleContent>
+ </complexType>
+
+</schema>
diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
index 7aab47f..3517b5a 100644
--- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
+++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
@@ -111,8 +111,8 @@ void tst_XmlPatternsValidator::xsdSupport()
process.start(m_command, arguments);
- QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
if(process.exitCode() != expectedExitCode)
QTextStream(stderr) << "foo:" << process.readAllStandardError();
@@ -197,20 +197,25 @@ void tst_XmlPatternsValidator::xsdSupport_data() const
<< (QStringList() << QLatin1String("files/instance.xml"))
<< QString();
- QTest::newRow("A schema with an indirectly included type")
+ QTest::newRow("QTBUG-8394 A schema with an indirectly included type")
<< 0
<< (QStringList() << QLatin1String("files/indirect-include-a.xsd"))
<< QString();
- QTest::newRow("A schema with an indirectly imported type")
+ QTest::newRow("QTBUG-8394 A schema with an indirectly imported type")
<< 0
<< (QStringList() << QLatin1String("files/indirect-import-a.xsd"))
<< QString();
- QTest::newRow("A schema with an indirectly redefined type")
+ QTest::newRow("QTBUG-8394 A schema with an indirectly redefined type")
<< 0
<< (QStringList() << QLatin1String("files/indirect-redefine-a.xsd"))
<< QString();
+
+ QTest::newRow("QTBUG-8920 A schema with a complex type that indirectly includes an anonymous type")
+ << 0
+ << (QStringList() << QLatin1String("files/complex-type-including-anonymous-type.xsd"))
+ << QString();
}
QTEST_MAIN(tst_XmlPatternsValidator)