diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-05-12 16:59:50 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-05-18 02:21:31 +0200 |
commit | 07d80deeab64db9e10364a162f7d2b7bf9f8bb93 (patch) | |
tree | ff0f30e401cf0f45598d39cba7764ba054b1eea7 /src/widgets/dialogs | |
parent | cf3843a2684c434a4800a7c11071e77f45817b70 (diff) |
QtWidgets: restore Qt 5 compatibility for save/restore state
Several classes in QWidget use QDataStream internally in order
to save and restore state. These QDataStream usages were not
versioned, meaning that if Qt changes the serialization for some
datatype, then the data saved between different Qt versions becomes
incompatible. Note that the save/restore API in question just produce
opaque blobs as QByteArrays -- the user has no control over the
QDataStream objects and thus versions.
Fix by version the usages.
In QHeaderView this has caused a regression because QBitArray *did*
change version between Qt 5 and 6. In general, using QDataStream without
explicit versioning is a mistake, so deploy the same fix elsewhere as
well.
Fixes: QTBUG-99487
Pick-to: 5.15 6.2 6.3
Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: <doctor.whom@gmail.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index ae8d0c137a..966d86b089 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -418,6 +418,7 @@ QByteArray QFileDialog::saveState() const int version = 4; QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); + stream.setVersion(QDataStream::Qt_5_0); stream << qint32(QFileDialogMagic); stream << qint32(version); @@ -452,6 +453,7 @@ bool QFileDialog::restoreState(const QByteArray &state) Q_D(QFileDialog); QByteArray sd = state; QDataStream stream(&sd, QIODevice::ReadOnly); + stream.setVersion(QDataStream::Qt_5_0); if (stream.atEnd()) return false; QStringList history; |