From 9af0eee33871228151e0369074c38d556a282f8c Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 7 Oct 2015 15:16:05 +0200 Subject: [PATCH] Fail to save sketch if user attempts to save it with the same name of one of its tabs, excluding the first. Fixes #3914 --- app/src/processing/app/Sketch.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 9c6a93c59..d317b4dfe 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -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; } }