Core: Fix flaw in XMLReader class

Remove implementation details of the Document class from the XMLReader class.
Instead keep an array of failed files and check them in the calling instance.
This commit is contained in:
wmayer
2024-11-16 14:47:56 +01:00
committed by wwmayer
parent 89d1d717eb
commit 6f8abe880c
4 changed files with 26 additions and 9 deletions

View File

@@ -1007,7 +1007,8 @@ void Document::Restore(Base::XMLReader &reader)
if (reader.hasAttribute("StringHasher")) {
d->Hasher->Restore(reader);
} else {
}
else {
d->Hasher->clear();
}
@@ -1075,6 +1076,17 @@ void Document::Restore(Base::XMLReader &reader)
reader.readEndElement("Document");
}
void DocumentP::checkStringHasher(const Base::XMLReader& reader)
{
if (reader.hasReadFailed("StringHasher.Table.txt")) {
Base::Console().Error(QT_TRANSLATE_NOOP(
"Notifications",
"\nIt is recommended that the user right-click the root of "
"the document and select Mark to recompute.\n"
"The user should then click the Refresh button in the main toolbar.\n"));
}
}
std::pair<bool,int> Document::addStringHasher(const StringHasherRef & hasher) const {
if (!hasher)
return std::make_pair(false, 0);
@@ -2118,6 +2130,8 @@ void Document::restore (const char *filename,
signalRestoreDocument(reader);
reader.readFiles(zipstream);
DocumentP::checkStringHasher(reader);
if (reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestore)) {
setStatus(Document::PartialRestore, true);
Base::Console().Error("There were errors while loading the file. Some data might have been modified or not recovered at all. Look above for more specific information about the objects involved.\n");