From ac9e2411ac06aba6dedf93023046c942937c321a Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sun, 19 Aug 2018 14:03:55 -0500 Subject: [PATCH] Fix variable scope for swap profile routine Resolves issue #394 --- DS4Windows/DS4Forms/DS4Form.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 8edb4cf..fa9d9c2 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -535,30 +535,33 @@ namespace DS4Windows string slide = Program.rootHub.TouchpadSlide(i); if (slide == "left") { + int ind = i; this.BeginInvoke((System.Action)(() => { - if (cbs[i].SelectedIndex <= 0) - cbs[i].SelectedIndex = cbs[i].Items.Count - 2; + if (cbs[ind].SelectedIndex <= 0) + cbs[ind].SelectedIndex = cbs[ind].Items.Count - 2; else - cbs[i].SelectedIndex--; + cbs[ind].SelectedIndex--; })); } else if (slide == "right") { + int ind = i; this.BeginInvoke((System.Action)(() => { - if (cbs[i].SelectedIndex == cbs[i].Items.Count - 2) - cbs[i].SelectedIndex = 0; + if (cbs[ind].SelectedIndex == cbs[ind].Items.Count - 2) + cbs[ind].SelectedIndex = 0; else - cbs[i].SelectedIndex++; + cbs[ind].SelectedIndex++; })); } if (slide.Contains("t")) { + int ind = i; this.BeginInvoke((System.Action)(() => { - ShowNotification(this, Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", cbs[i].Text)); + ShowNotification(this, Properties.Resources.UsingProfile.Replace("*number*", (ind + 1).ToString()).Replace("*Profile name*", cbs[ind].Text)); })); } }