Check that QIODevice::open() is successful, and explicitly call close()

This commit is contained in:
Jonas Kvinge
2021-07-14 20:52:57 +02:00
parent f64c1dd9e5
commit 2eab763d74
15 changed files with 74 additions and 49 deletions

View File

@@ -340,11 +340,11 @@ bool CommandlineOptions::contains_play_options() const {
QByteArray CommandlineOptions::Serialize() const {
QBuffer buf;
buf.open(QIODevice::WriteOnly);
QDataStream s(&buf);
s << *this;
buf.close();
if (buf.open(QIODevice::WriteOnly)) {
QDataStream s(&buf);
s << *this;
buf.close();
}
return buf.data().toBase64();
@@ -354,10 +354,10 @@ void CommandlineOptions::Load(const QByteArray &serialized) {
QByteArray copy = QByteArray::fromBase64(serialized);
QBuffer buf(&copy);
buf.open(QIODevice::ReadOnly);
QDataStream s(&buf);
s >> *this;
if (buf.open(QIODevice::ReadOnly)) {
QDataStream s(&buf);
s >> *this;
}
}