B2020-004: Enhanced flag ‘allowmods’ caused crash on open of non-enhanced procedure after version properties change

This commit is contained in:
Kathy Ruffing 2020-01-14 15:04:46 +00:00
parent 213e7b297e
commit d1fba22cc3
2 changed files with 8 additions and 3 deletions

View File

@ -229,6 +229,9 @@ namespace VEPROMS
}
}
}
// B2020-004: only set allowmods if this is an enhanced:
bool isEnhanced = (_DocVersionConfig.MyEnhancedDocuments != null && _DocVersionConfig.MyEnhancedDocuments.Count == 1 && _DocVersionConfig.MyEnhancedDocuments[0].Type == 0);
if (isEnhanced) _DocVersionConfig.Enhanced_AllowMods = ppChbxEnhancedAllowMods.Checked;
_DocVersionConfig.SaveDVEnhancedDocuments();
}
@ -243,7 +246,6 @@ namespace VEPROMS
_DocVersionConfig.Print_MergedPdfsPageNumLocY = float.Parse(tbxMOSyloc.Text);
_DocVersionConfig.Print_MergedPdfsPageNumCorner = (MergedPdfsPageNumCorner)ppCmbxMOScornerLoc.SelectedIndex;
_DocVersionConfig.Print_MergedPdfsViewAfter = ppChbxMOSview.Checked;
_DocVersionConfig.Enhanced_AllowMods = ppChbxEnhancedAllowMods.Checked; // C2019-045: allow modification of enhanced procedure num/title
//docVersionConfigBindingSource.EndEdit();
// Save Default settings for User
@ -547,7 +549,6 @@ namespace VEPROMS
else
ppCmbxMOSfontName.SelectedValue = _DocVersionConfig.Print_MergedPdfsPageNumFont;
ppChbxMOSview.Checked = _DocVersionConfig.Print_MergedPdfsViewAfter;
ppChbxEnhancedAllowMods.Checked = _DocVersionConfig.Enhanced_AllowMods;
_Initializing = false;
}
@ -604,6 +605,7 @@ namespace VEPROMS
// isEnhanced is an already existing enhanced document. Only allow the user to change the Pdf settings:
if (isEnhanced)
{
ppChbxEnhancedAllowMods.Checked = _DocVersionConfig.Enhanced_AllowMods; // B2020-004: allowmods only if this is an enhanced
_Enhanced = new List<EnhancedMiniConfig>();
// only display the data from the config setting. And only allow modify of PdfID and PdfXoffset
lbEnhanced.Visible = false;

View File

@ -16,9 +16,12 @@ namespace VEPROMS.CSLA.Library
}
public static DVEnhancedDocuments Load(XMLProperties _Xp)
{
DVEnhancedDocuments eds = new DVEnhancedDocuments();
DVEnhancedDocuments eds = null;
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
XmlAttribute xa = xn.Attributes["VersionID"];
if (xa == null) return null; // B2020-004: if an enhanced node exists but has no version data, return null.
if (eds == null) eds = new DVEnhancedDocuments();
int dvid = int.Parse(xn.Attributes["VersionID"].Value);
DocVersionInfo dvi = DocVersionInfo.Get(dvid);
if (dvi != null)