From a5b9d3113477701c92a38693dd70436e11bcce29 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 28 Jan 2010 21:19:53 +0000 Subject: [PATCH] Stopping you from renaming the main / first sketch file (.pde) if it contains a .cpp file with the new name. --- app/src/processing/app/Sketch.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index d32f14b7b..29c2c3976 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -407,6 +407,19 @@ public class Sketch { "You can't have a .cpp file with the same name as the sketch."); return; } + + if (currentIndex == 0) { + for (int i = 1; i < codeCount; i++) { + if (sanitaryName.equalsIgnoreCase(code[i].getPrettyName()) && + code[i].getExtension().equalsIgnoreCase("cpp")) { + Base.showMessage("Nope", + "You can't rename the sketch to \"" + sanitaryName + "\"\n" + + "because the sketch already has a .cpp file with that name."); + return; + } + } + } + File newFile = new File(folder, newName); // if (newFile.exists()) { // yay! users will try anything