Skip to content
Snippets Groups Projects
Commit 2017c1c9 authored by akmokhtari's avatar akmokhtari
Browse files

Handle the case when no electrode is selected

This fixes a segfault that happened when no electrode was selected on a spike detector (e.g., with no electrodes added); getSelectedItemIndex returns -1 in this case, which was causing an array bounds segfault in drawElectrodeButtons.
parent 87703b97
No related branches found
No related tags found
No related merge requests found
......@@ -275,10 +275,18 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
}
if (!button->getToggleState()) {
thresholdSlider->setActive(false);
electrodeButtons.clear();
drawElectrodeButtons(electrodeList->getSelectedItemIndex());
if (!button->getToggleState())
{
thresholdSlider->setActive(false);
// This will be -1 with nothing selected
int selectedItemIndex = electrodeList->getSelectedItemIndex();
if (selectedItemIndex != -1)
{
drawElectrodeButtons(selectedItemIndex);
} else {
electrodeButtons.clear();
}
}
// channelSelector->setActiveChannels(activeChannels);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment