From 6c102919f5afcbc3c16896989f7be9fcbb420bf5 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 1 Oct 2019 19:13:15 -0700 Subject: [PATCH] Fix Actions menu crash If you open the Actions menu when nothing is selected, the "can I create a local variable table here" method crashes with a bad index reference. Issue #48. --- SourceGen/MainController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index 2c3eadf..530dee3 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -1650,8 +1650,11 @@ namespace SourceGen { } public bool CanCreateLocalVariableTable() { - int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex(); + if (SelectionAnalysis.mNumItemsSelected != 1) { + return false; + } // Only allow on code lines. This is somewhat arbitrary; data would work fine. + int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex(); if (CodeLineList[selIndex].LineType != LineListGen.Line.Type.Code) { return false; }