Skip to content

Commit

Permalink
fix when ocr file in settings cannot be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Jan 18, 2021
1 parent e47656f commit 0af7ea5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.43.0.2")]
[assembly: AssemblyFileVersion("0.43.0.3")]
[assembly: NeutralResourcesLanguage("en")]

13 changes: 11 additions & 2 deletions ARKBreedingStats/ocr/OCRControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public OCRControl()
public void Initialize()
{
SetWhiteThreshold(Properties.Settings.Default.OCRWhiteThreshold);
LoadAndInitializeOcrTemplate(Properties.Settings.Default.ocrFile);
if (!LoadAndInitializeOcrTemplate(Properties.Settings.Default.ocrFile))
Properties.Settings.Default.ocrFile = null;
}

private void InitLabelEntries()
Expand Down Expand Up @@ -449,8 +450,16 @@ private bool LoadAndInitializeOcrTemplate(string filePath)
return false;
}

ArkOCR.OCR.ocrConfig = OCRTemplate.LoadFile(filePath) ?? new OCRTemplate();
var loadedOcrConfig = OCRTemplate.LoadFile(filePath);
if (loadedOcrConfig == null)
{
filePath = null;
}

ArkOCR.OCR.ocrConfig = loadedOcrConfig;
UpdateOCRLabel(filePath);
if (loadedOcrConfig == null) return false;

UpdateOcrFontSizes();
InitLabelEntries();
nudResizing.Value = ArkOCR.OCR.ocrConfig.resize == 0 ? 1 : (decimal)ArkOCR.OCR.ocrConfig.resize;
Expand Down

0 comments on commit 0af7ea5

Please sign in to comment.