serializer: improved robustness of project saving... maybe?

This seems to address a bug where sometimes QXmlStreamWriter would insert nonsense null characters into a project. This is probably some real edge case like compiler optimization or some bullshit like that. I don't even know if it affects all platforms, but it definitely affected me.
This commit is contained in:
itsmattkc
2022-07-20 21:26:49 -07:00
parent bb4bbb4fd7
commit 16bd15ad42
2 changed files with 98 additions and 83 deletions
+6 -5
View File
@@ -159,6 +159,11 @@ ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data, const QS
Result inner_result = Save(&writer, data, type);
if (writer.hasError()) {
Result r(kXmlError);
return r;
}
project_file.close();
if (inner_result != kSuccess) {
@@ -261,12 +266,8 @@ ProjectSerializer::Result ProjectSerializer::LoadWithSerializerVersion(uint vers
LoadData ld = serializer->Load(project, reader, nullptr);
Result r(kSuccess);
if (reader->hasError()) {
qWarning() << "XML error:" << reader->errorString() << "at:";
for (int i=0; i<50; i++) {
qWarning() << reader->device()->readLine();
}
r = Result(kXmlError);
r.SetDetails(reader->errorString());
r.SetDetails(QCoreApplication::translate("Serializer", "%1 on line %2").arg(reader->errorString(), QString::number(reader->lineNumber())));
}
r.SetLoadData(ld);
return r;