Skip to content

Commit

Permalink
Dont allow blank patch names or categories
Browse files Browse the repository at this point in the history
Prompt a user error in this case rather than making blank named files
  • Loading branch information
baconpaul committed Jan 17, 2019
1 parent 8be63a3 commit a6c3426
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "vstcontrols.h"
#include "SurgeBitmaps.h"
#include "CNumberField.h"
#include "UserInteractions.h"

#if TARGET_AUDIOUNIT
#include "aulayer.h"
Expand Down Expand Up @@ -2127,11 +2128,35 @@ void SurgeGUIEditor::valueChanged(CControl* control)
// frame->setModalView(nullptr);
frame->setDirty();

synth->storage.getPatch().name = patchName->getText();
synth->storage.getPatch().author = patchCreator->getText();
synth->storage.getPatch().category = patchCategory->getText();
synth->storage.getPatch().comment = patchComment->getText();
synth->savePatch();
/*
** Don't allow a blank patch
*/
std::string whatIsBlank = "";
bool haveBlanks = false;

if (std::string(patchName->getText()).find_first_not_of( ' ' ) == std::string::npos)
{
whatIsBlank = "name"; haveBlanks = true;
}
if (std::string(patchCategory->getText()).find_first_not_of( ' ' ) == std::string::npos)
{
whatIsBlank = whatIsBlank + (haveBlanks? " and category" : "category"); haveBlanks = true;
}
if (haveBlanks)
{
Surge::UserInteractions::promptError(std::string("Unable to store a patch with a blank ") +
whatIsBlank + ". Please save again and provide a complete " +
whatIsBlank + ".",
"Error saving patch");
}
else
{
synth->storage.getPatch().name = patchName->getText();
synth->storage.getPatch().author = patchCreator->getText();
synth->storage.getPatch().category = patchCategory->getText();
synth->storage.getPatch().comment = patchComment->getText();
synth->savePatch();
}
}
break;
default:
Expand Down

0 comments on commit a6c3426

Please sign in to comment.