B2023-072: Crash when restoring annotation whose type had been removed

This commit is contained in:
2023-06-13 12:59:43 +00:00
parent fe270e55c7
commit be72063a3c
2 changed files with 12 additions and 1 deletions

View File

@@ -827,6 +827,16 @@ namespace Volian.Controls.Library
if (FlexibleMessageBox.Show(this, "Do you want to restore this annotation?", "Confirm Annotation Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
AnnotationInfo ai = AnnotationInfo.RestoreAnnotation(aai);
// B2023-072: Don't crash if annotation type was deleted for the restore annotation
if (ai == null)
{
AnnotationTypeInfo ati = AnnotationTypeInfo.Get(aai.TypeID);
if (ati == null)
{
FlexibleMessageBox.Show(this, "Annotation Type was deleted, cannot restore Annotation Type\r\nCopy text from window in Change Details and paste into new annotation to restore the text.", "Annotation Type Deleted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
return;
}
OnAnnotationRestored(ai, ai.MyItem);
RefreshRequired = true;
UpdateHistory();