Skip to content

Commit 9af0eee

Browse files
author
Federico Fissore
committed
Fail to save sketch if user attempts to save it with the same name of one of its tabs, excluding the first. Fixes #3914
1 parent 651ae04 commit 9af0eee

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

app/src/processing/app/Sketch.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,13 @@ protected boolean saveAs() throws IOException {
652652
// make sure there doesn't exist a .cpp file with that name already
653653
// but ignore this situation for the first tab, since it's probably being
654654
// resaved (with the same name) to another location/folder.
655-
for (SketchCode code : data.getCodes()) {
656-
if (newName.equalsIgnoreCase(code.getPrettyName()) && code.isExtension("cpp")) {
655+
for (int i = 0; i < data.getCodeCount(); i++) {
656+
SketchCode code = data.getCode(i);
657+
if (newName.equalsIgnoreCase(code.getPrettyName())) {
657658
Base.showMessage(tr("Error"),
658-
I18n.format(
659-
tr("You can't save the sketch as \"{0}\"\n" +
660-
"because the sketch already has a .cpp file with that name."),
661-
newName
662-
));
659+
I18n.format(tr("You can't save the sketch as \"{0}\"\n" +
660+
"because the sketch already has a file with that name."), newName
661+
));
663662
return false;
664663
}
665664
}

0 commit comments

Comments
 (0)