Fail to save sketch if user attempts to save it with the same name of one of its tabs, excluding the first. Fixes #3914

This commit is contained in:
Federico Fissore 2015-10-07 15:16:05 +02:00
parent 651ae04a19
commit 9af0eee338
1 changed files with 6 additions and 7 deletions

View File

@ -652,14 +652,13 @@ public class Sketch {
// make sure there doesn't exist a .cpp file with that name already
// but ignore this situation for the first tab, since it's probably being
// resaved (with the same name) to another location/folder.
for (SketchCode code : data.getCodes()) {
if (newName.equalsIgnoreCase(code.getPrettyName()) && code.isExtension("cpp")) {
for (int i = 0; i < data.getCodeCount(); i++) {
SketchCode code = data.getCode(i);
if (newName.equalsIgnoreCase(code.getPrettyName())) {
Base.showMessage(tr("Error"),
I18n.format(
tr("You can't save the sketch as \"{0}\"\n" +
"because the sketch already has a .cpp file with that name."),
newName
));
I18n.format(tr("You can't save the sketch as \"{0}\"\n" +
"because the sketch already has a file with that name."), newName
));
return false;
}
}