[TD]protect against bad pref value

- this is a temporary measure to prevent problems caused by a
  bad value for LineStandard parameter.  A previous devel version
  stored on invalid value.  This patch can be removed before
  moving to production.
- this condition can be corrected by editing LineStandard to 0, 1 or
  2.  a plethora of warning messages is issued until the parameter is
  corrected.
This commit is contained in:
wandererfan
2024-03-22 18:22:47 -04:00
committed by WandererFan
parent 300bff8b4a
commit 6337b454e1
2 changed files with 24 additions and 1 deletions

View File

@@ -362,6 +362,17 @@ std::string LineGenerator::getLineStandardsBody()
{
int activeStandard = Preferences::lineStandard();
std::vector<std::string> choices = getAvailableLineStandards();
if (activeStandard < 0 ||
(size_t) activeStandard >= choices.size()) {
// there is a condition where the LineStandard parameter exists, but is -1 (the
// qt value for no current index in a combobox). This is likely caused by an old
// development version writing an unvalidated value. In this case, the existing but
// invalid value will be returned. This is a temporary fix and can be removed for
// production.
// Preferences::lineStandard() will print a message about this every time it is called
// (lots of messages!).
activeStandard = 0;
}
return getBodyFromString(choices.at(activeStandard));
}