summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdatastream.h
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2016-06-17 15:07:26 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2016-07-20 06:52:43 +0000
commit902a5e7aaa0ec156d19b5a7988eff1809a6a2046 (patch)
tree6fb8b610878f92bab90a430dac95a3be9805a06f /src/corelib/io/qdatastream.h
parent9467bdc9093d9b02e249c6cce508b9df3ff8b2f4 (diff)
QDataStream: adjust containers' deserialization in transaction mode
If an error occurs during the transaction, we should prevent the containers from being successfully read. So, check the status of the stream before reading the container, because the deserialization procedure temporarily resets it on entry. Task-number: QTBUG-54022 Change-Id: Ie955c2fa3e449374f0f8403f00e487efa2bfdaf3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/io/qdatastream.h')
-rw-r--r--src/corelib/io/qdatastream.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 260dd519e3..e8634fddef 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -63,6 +63,9 @@ template <class Key, class T> class QMap;
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
class QDataStreamPrivate;
+namespace QtPrivate {
+class StreamStateSaver;
+}
class Q_CORE_EXPORT QDataStream
{
public:
@@ -192,6 +195,7 @@ private:
Status q_status;
int readBlock(char *data, int len);
+ friend class QtPrivate::StreamStateSaver;
};
namespace QtPrivate {
@@ -201,7 +205,8 @@ class StreamStateSaver
public:
inline StreamStateSaver(QDataStream *s) : stream(s), oldStatus(s->status())
{
- stream->resetStatus();
+ if (!stream->dev || !stream->dev->isTransactionStarted())
+ stream->resetStatus();
}
inline ~StreamStateSaver()
{