B2020-045: Generating Library Document Report crashes when no library document is selected
This commit is contained in:
parent
ae4431b327
commit
9d4f7e8765
@ -304,7 +304,28 @@ namespace Volian.Controls.Library
|
||||
private void btnPrint_Click(object sender, EventArgs e)
|
||||
{
|
||||
string paperSize = "Letter";
|
||||
paperSize = LibDocList[listBoxLibDocs.SelectedIndex].LibraryDocumentUsageList[0].ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
|
||||
// B2020-045: Getting Library Document usage report when no documents are selected crashes with a null reference if the first
|
||||
// in libdoc usage list is null (added code that finds a non-null usage list and uses first to get format. Otherwise
|
||||
// uses the default "Letter" paper size).
|
||||
ItemInfo ii = null;
|
||||
int sel = listBoxLibDocs.SelectedIndex < 0 ? 0 : listBoxLibDocs.SelectedIndex;
|
||||
if (LibDocList[sel].LibraryDocumentUsageList == null || LibDocList[sel].LibraryDocumentUsageList.Count == 0)
|
||||
{
|
||||
// selected lib doc doesn't have usages, loop through to find one. Need a usage to get the active format
|
||||
for (int i = 0; i<LibDocList.Count; i++)
|
||||
{
|
||||
if (LibDocList[i].LibraryDocumentUsageList != null && LibDocList[i].LibraryDocumentUsageList.Count>0)
|
||||
{
|
||||
ii = LibDocList[i].LibraryDocumentUsageList[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ii = LibDocList[sel].LibraryDocumentUsageList[0];
|
||||
|
||||
if (ii != null)
|
||||
paperSize = ii.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
|
||||
OnPrintRequest(new DisplayLibDocEventArgs("Library Document Usage", LibDocList, paperSize));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user