1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

AUP3: Fix recovery for project without autosave or project docs

Also fixes a connection restoration issue that I can't believe
didn't cause all manner of issues.
This commit is contained in:
Leland Lucius 2020-08-02 01:39:19 -05:00
parent 9f058dc308
commit 0dca04dc3b

View File

@ -1797,52 +1797,54 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName)
// Error already set
return false;
}
// Missing both the autosave and project docs. This can happen if the
// system were to crash before the first autosave into a temporary file.
if (buffer.GetDataLen() == 0)
{
SetError(XO("Unable to load project or autosave documents"));
return false;
}
}
// Decode it while capturing the associated sample blockids
project = ProjectSerializer::Decode(buffer, blockids);
if (project.empty())
{
SetError(XO("Unable to decode project document"));
return false;
}
// Check for orphans blocks...sets mRecovered if any were deleted
if (blockids.size() > 0)
{
if (!DeleteBlocks(blockids, true))
{
return false;
}
}
XMLFileReader xmlFile;
// Load 'er up
success = xmlFile.ParseString(this, project);
if (!success)
{
SetError(
XO("Unable to parse project information.")
);
mLibraryError = xmlFile.GetErrorStr();
return false;
}
// Remember if we used autosave or not
if (usedAutosave)
// Missing both the autosave and project docs. This can happen if the
// system were to crash before the first autosave into a temporary file.
// This should be a recoverable scenario.
if (buffer.GetDataLen() == 0)
{
mRecovered = true;
}
else
{
// Decode it while capturing the associated sample blockids
project = ProjectSerializer::Decode(buffer, blockids);
if (project.empty())
{
SetError(XO("Unable to decode project document"));
return false;
}
// Check for orphans blocks...sets mRecovered if any were deleted
if (blockids.size() > 0)
{
if (!DeleteBlocks(blockids, true))
{
return false;
}
}
XMLFileReader xmlFile;
// Load 'er up
success = xmlFile.ParseString(this, project);
if (!success)
{
SetError(
XO("Unable to parse project information.")
);
mLibraryError = xmlFile.GetErrorStr();
return false;
}
// Remember if we used autosave or not
if (usedAutosave)
{
mRecovered = true;
}
}
// Mark the project modified if we recovered it
if (mRecovered)
@ -1865,6 +1867,8 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName)
DiscardConnection();
success = true;
return true;
}