Skip to content

Commit b24f9f7

Browse files
committed
Fixed issue with the Issues dialog attempting to jump to an invalid layout/card index.
1 parent 2fbc12e commit b24f9f7

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

CardMaker/Forms/MDIIssues.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ private void listViewIssues_SelectedIndexChanged(object sender, EventArgs e)
9393
{
9494
if (1 == listViewIssues.SelectedItems.Count)
9595
{
96-
ListViewItem zItem = listViewIssues.SelectedItems[0];
97-
int nLayout = int.Parse(zItem.SubItems[0].Text);
98-
int nCard = int.Parse(zItem.SubItems[1].Text);
99-
// Select the Layout
100-
LayoutManager.Instance.FireLayoutSelectRequested(ProjectManager.Instance.LoadedProject.Layout[nLayout]);
101-
// Select the Element
102-
ElementManager.Instance.FireElementSelectRequestedEvent(LayoutManager.Instance.GetElement(zItem.SubItems[2].Text));
103-
// Select the Card Index
104-
LayoutManager.Instance.FireDeckIndexChangeRequested(nCard - 1);
96+
var zItem = listViewIssues.SelectedItems[0];
97+
var nLayout = (int) zItem.Tag;
98+
int nCard;
99+
100+
if (int.TryParse(zItem.SubItems[1].Text, out nCard))
101+
{
102+
// Select the Layout
103+
LayoutManager.Instance.FireLayoutSelectRequested(ProjectManager.Instance.LoadedProject.Layout[nLayout]);
104+
// Select the Element
105+
ElementManager.Instance.FireElementSelectRequestedEvent(LayoutManager.Instance.GetElement(zItem.SubItems[2].Text));
106+
// Select the Card Index
107+
LayoutManager.Instance.FireDeckIndexChangeRequested(nCard - 1);
108+
}
105109
}
106110
}
107111

@@ -136,12 +140,14 @@ private void AddIssue(string sIssue)
136140

137141
if (listViewIssues.InvokeActionIfRequired(() => AddIssue(sIssue)))
138142
{
143+
// NOTE: The tag stores the index of the layout
139144
var zItem = new ListViewItem(new string[] {
140145
ProjectManager.Instance.LoadedProject.Layout[m_nCurrentLayoutIndex].Name,
141146
m_sCurrentCardIndex,
142147
m_sCurrentElementName,
143148
sIssue
144149
});
150+
zItem.Tag = m_nCurrentLayoutIndex;
145151
listViewIssues.Items.Add(zItem);
146152
}
147153
}

0 commit comments

Comments
 (0)