NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

commit a19a7b5f741a7f41c2b58fe510af6787c8370d8d
parent f1cee374083e24a81c0eada7b154762eb1ff5d95
Author: Steven Atkinson <[email protected]>
Date:   Fri, 16 Jun 2023 23:45:25 -0700

Update NeuralampModelerControls.h

Avoid doing anything on prevFileFunc and nextFileFunc if there are no items.

Diffstat:
MNeuralAmpModeler/NeuralAmpModelerControls.h | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -181,18 +181,24 @@ public: void OnAttached() override { auto prevFileFunc = [&](IControl* pCaller) { + const auto nItems = NItems(); + if (nItems == 0) + return; mSelectedIndex--; if (mSelectedIndex < 0) - mSelectedIndex = NItems() - 1; + mSelectedIndex = nItems - 1; LoadFileAtCurrentIndex(); }; auto nextFileFunc = [&](IControl* pCaller) { + const auto nItems = NItems(); + if (nItems == 0) + return; mSelectedIndex++; - if (mSelectedIndex >= NItems()) + if (mSelectedIndex >= nItems) mSelectedIndex = 0; LoadFileAtCurrentIndex(); @@ -270,7 +276,7 @@ public: void LoadFileAtCurrentIndex() { - if (mSelectedIndex > -1 && mSelectedIndex < mItems.GetSize()) + if (mSelectedIndex > -1 && mSelectedIndex < NItems()) { WDL_String fileName, path; GetSelectedFile(fileName);