Merge pull request #120 from MihaelaStoica/CA-139588

CA-139588: Try to prevent Index was out of range exception by invoking o...
This commit is contained in:
Stephen Turner 2014-07-10 14:44:26 +01:00
commit 8deb94d290

View File

@ -119,7 +119,12 @@ namespace XenAdmin.Dialogs
private void checkableDataGridView_RowUpdated(object sender, CheckableDataGridViewRowEventArgs e) private void checkableDataGridView_RowUpdated(object sender, CheckableDataGridViewRowEventArgs e)
{ {
LicenseCheckableDataGridView senderGrid = sender as LicenseCheckableDataGridView; LicenseCheckableDataGridView senderGrid = sender as LicenseCheckableDataGridView;
if (senderGrid == null || e.RowIndex >= senderGrid.Rows.Count || e.RowIndex < 0) if (senderGrid == null)
return;
Program.Invoke(this, delegate
{
if (e.RowIndex >= senderGrid.Rows.Count || e.RowIndex < 0)
return; return;
LicenseDataGridViewRow lRow = senderGrid.Rows[e.RowIndex] as LicenseDataGridViewRow; LicenseDataGridViewRow lRow = senderGrid.Rows[e.RowIndex] as LicenseDataGridViewRow;
@ -128,11 +133,11 @@ namespace XenAdmin.Dialogs
Controller.SetStatusIcon(e.RowIndex, lRow.RowStatus); Controller.SetStatusIcon(e.RowIndex, lRow.RowStatus);
if (senderGrid.SelectedRows.Count >= 1 && senderGrid.SelectedRows[0].Index == e.RowIndex) if (senderGrid.SelectedRows.Count > 0 && senderGrid.SelectedRows[0].Index == e.RowIndex)
{ {
Controller.SummariseSelectedRow(checkableDataGridView.GetCheckableRow(e.RowIndex)); Controller.SummariseSelectedRow(checkableDataGridView.GetCheckableRow(e.RowIndex));
} }
});
if (e.RefreshGrid) if (e.RefreshGrid)
senderGrid.SortAndRefresh(); senderGrid.SortAndRefresh();
} }