NOTE: I made some changes to comments here, so it's not a full 1:1
reapplication. However, this still fixes an issue with Tenacity failing
to open projects created in older versions of itself.

--------------------

Restore compatibility with Audacity-created projects

PR #84 introduced new project compatibility code taken from upstream.
However, this project compatibility code was geared towards focusing on
dealing with newer and older versions of Audacity, not Tenacity. This
resulted in Tenacity failing to open projects it created in prior
versions because of incorrectly assuming that the project was created in
a newer version of Tenacity when this was not the case. To fix this, the
following was introduced:

1. Add new version constants to represent Tenacity's version.

2. Check the project version against the Audacity version constants.
   This will succeed even if the project was created or updated in
   Tenacity.

While the solution is not ideal, it provides a temporary fix.
Unfortunately, we do not have a clear way of distinguising ourselves
from Audacity projects right now, but there might be ways that we can
distinguish ourselves from Audacity projects in the future.

Signed-off-by: Avery King <avery98@pm.me>
(cherry picked from commit d55cf9a34d)
Signed-off-by: Avery King <gperson@disroot.org>
This commit is contained in:
Avery King
2022-12-24 16:59:26 -08:00
committed by Avery King
parent 4b2d5a5420
commit f628980d7d
3 changed files with 22 additions and 8 deletions

View File

@@ -774,10 +774,12 @@ bool ProjectFileIO::CheckVersion()
// Project file version is higher than ours. We will refuse to
// process it since we can't trust anything about it.
if (SupportedProjectFormatVersion < version)
// TODO: use the SupportedProjectFormatVersion instead and make a way to
// clearly distinguish projects created by either Audacity or Tenacity.
if (SupportedAudacityProjectFormatVersion < version)
{
SetError(
XO("This project was created with a newer version of Audacity.\n\nYou will need to upgrade to open it.")
XO("This project was created with a version of Audacity that is not supported by Tenacity.\n\nYou will need to use that version to open it.")
);
return false;
}
@@ -785,8 +787,8 @@ bool ProjectFileIO::CheckVersion()
using namespace BasicUI;
wxString currentVersionStr = wxString::Format("%u.%u", BaseProjectFormatVersion.Major, BaseProjectFormatVersion.Minor);
bool updateVersion = (MessageBoxResult::Yes == ShowMessageBox(
XO("This project was created using an older Audacity version. "
"Once saved, the project can only be opened with Audacity version %s or newer.").Format(currentVersionStr),
XO("This project was created using an older Tenacity version. "
"Once saved, the project can only be opened with Tenacity version %s or newer.").Format(currentVersionStr),
MessageBoxOptions{}
.Caption(XO("Project update required"))));
}

View File

@@ -50,7 +50,9 @@ bool ProjectFormatVersion::IsValid() const noexcept
}
const ProjectFormatVersion SupportedProjectFormatVersion = {
TENACITY_VERSION, TENACITY_RELEASE, TENACITY_REVISION, 0
TENACITY_VERSION, TENACITY_RELEASE, TENACITY_REVISION, 0, true
};
const ProjectFormatVersion BaseProjectFormatVersion = { TENACITY_VERSION, TENACITY_RELEASE, 0, 0 };
const ProjectFormatVersion SupportedAudacityProjectFormatVersion = { 3, 7, 0, 0, false };
const ProjectFormatVersion BaseProjectFormatVersion = { 1, 3, 0, 0, true };
const ProjectFormatVersion BaseAudacityProjectFormatVersion = { 3, 0, 0, 0, false };

View File

@@ -24,6 +24,7 @@ struct PROJECT_API ProjectFormatVersion final
uint8_t Minor { 0 };
uint8_t Revision { 0 };
uint8_t ModLevel { 0 };
bool IsTenacity { false };
// Create ProjectFormatVersion from the uint32_t value
static ProjectFormatVersion FromPacked(uint32_t) noexcept;
@@ -38,7 +39,16 @@ PROJECT_API bool operator==(ProjectFormatVersion lhs, ProjectFormatVersion rhs)
PROJECT_API bool operator!=(ProjectFormatVersion lhs, ProjectFormatVersion rhs) noexcept;
PROJECT_API bool operator<(ProjectFormatVersion lhs, ProjectFormatVersion rhs) noexcept;
//! This constant represents the current version of Audacity
/// This constant represents the current version of Tenacity.
PROJECT_API extern const ProjectFormatVersion SupportedProjectFormatVersion;
//! This is a helper constant for the "most compatible" project version which is the current MAJ.MIN.0.0
/// This constant represents the maximum supported Audacity project version.
PROJECT_API extern const ProjectFormatVersion SupportedAudacityProjectFormatVersion;
/// This is a helper constant for the "most compatible" project version created
/// by Tenacity with the value (MAJ, MIN, 0, 0).
PROJECT_API extern const ProjectFormatVersion BaseProjectFormatVersion;
/// This is a helper constant for the "most compatible" project version created
/// by Audacity with the value {AUD_MAJ, AUD_MIN, 0, 0}.
PROJECT_API extern const ProjectFormatVersion BaseAudacityProjectFormatVersion;