Skip to content

Commit

Permalink
Handle totally clean machine startup path (surge-synthesizer#5285)
Browse files Browse the repository at this point in the history
Threw a debug exception in that situation

Closes surge-synthesizer#5284`
  • Loading branch information
baconpaul authored Oct 21, 2021
1 parent dd5e129 commit 7bd8ce5
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3066,20 +3066,27 @@ juce::PopupMenu SurgeGUIEditor::makePatchDefaultsMenu(const juce::Point<int> &wh

patchDefMenu.addSeparator();

auto catCurId =
&(this->synth->storage).patch_category[patchSelector->getCurrentCategoryId()].name;
auto patchCurId = &(this->synth->storage).patch_list[patchSelector->getCurrentPatchId()].name;

patchDefMenu.addItem(
Surge::GUI::toOSCaseForMenu("Set Current Patch as Default"),
[this, catCurId, patchCurId]() {
Surge::Storage::updateUserDefaultValue(&(this->synth->storage),
Surge::Storage::InitialPatchName, *patchCurId);

Surge::Storage::updateUserDefaultValue(&(this->synth->storage),
Surge::Storage::InitialPatchCategory, *catCurId);
});
auto pscid = patchSelector->getCurrentCategoryId();
auto pspid = patchSelector->getCurrentPatchId();
auto s = &(this->synth->storage);
if (pscid >= 0 && pscid < s->patch_category.size() && pspid >= 0 &&
pspid < s->patch_list.size())
{
auto catCurId =
&(this->synth->storage).patch_category[patchSelector->getCurrentCategoryId()].name;
auto patchCurId =
&(this->synth->storage).patch_list[patchSelector->getCurrentPatchId()].name;

patchDefMenu.addItem(
Surge::GUI::toOSCaseForMenu("Set Current Patch as Default"),
[this, catCurId, patchCurId]() {
Surge::Storage::updateUserDefaultValue(
&(this->synth->storage), Surge::Storage::InitialPatchName, *patchCurId);

Surge::Storage::updateUserDefaultValue(
&(this->synth->storage), Surge::Storage::InitialPatchCategory, *catCurId);
});
}
return patchDefMenu;
}

Expand Down

0 comments on commit 7bd8ce5

Please sign in to comment.