Don't rely on the Qt version when reading a QHeaderView state stream

Since the datastream version is not set in previous versions of Qt when
streaming the state of the QHeaderView then we cannot rely on this when
adding new data to the state. Therefore we check if we read past the
end before assigning to the new variable.

Change-Id: I7128ffc91e47f9c8797cfa24d206a789d2814908
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
Andy Shaw 2013-10-07 16:01:53 +02:00 committed by The Qt Project
parent 5c87044870
commit 64332372a1

View File

@ -3693,8 +3693,7 @@ void QHeaderViewPrivate::write(QDataStream &out) const
out << int(globalResizeMode);
out << sectionItems;
if (out.version() >= QDataStream::Qt_5_2)
out << resizeContentsPrecision;
out << resizeContentsPrecision;
}
bool QHeaderViewPrivate::read(QDataStream &in)
@ -3747,8 +3746,10 @@ bool QHeaderViewPrivate::read(QDataStream &in)
sectionItems = newSectionItems;
recalcSectionStartPos();
if (in.version() >= QDataStream::Qt_5_2)
in >> resizeContentsPrecision;
int tmpint;
in >> tmpint;
if (in.status() == QDataStream::Ok) // we haven't read past end
resizeContentsPrecision = tmpint;
return true;
}