mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 08:30: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:
parent
9f058dc308
commit
0dca04dc3b
@ -1797,52 +1797,54 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName)
|
|||||||
// Error already set
|
// Error already set
|
||||||
return false;
|
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
|
// Missing both the autosave and project docs. This can happen if the
|
||||||
project = ProjectSerializer::Decode(buffer, blockids);
|
// system were to crash before the first autosave into a temporary file.
|
||||||
if (project.empty())
|
// This should be a recoverable scenario.
|
||||||
{
|
if (buffer.GetDataLen() == 0)
|
||||||
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;
|
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
|
// Mark the project modified if we recovered it
|
||||||
if (mRecovered)
|
if (mRecovered)
|
||||||
@ -1865,6 +1867,8 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName)
|
|||||||
|
|
||||||
DiscardConnection();
|
DiscardConnection();
|
||||||
|
|
||||||
|
success = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user