[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

@@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <string>
# include <QApplication>
# include <QString>
#endif
@@ -422,6 +422,18 @@ bool Preferences::SectionUsePreviousCut()
//! an index into the list of available line standards/version found in LineGroupDirectory
int Preferences::lineStandard()
{
// 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.
// this message will appear many times if the parameter is invalid.
int parameterValue = getPreferenceGroup("Standards")->GetInt("LineStandard", 1);
if (parameterValue < 0) {
Base::Console().Warning(qPrintable(QApplication::translate(
"Preferences", "The LineStandard parameter is invalid. Using zero instead.", nullptr)));
return 0;
}
return getPreferenceGroup("Standards")->GetInt("LineStandard", 1);
}