Skip to content

Commit 7c58be3

Browse files
bitroncmaglie
authored andcommitted
Fixed wrong sketch structure check in Editor and SketchData.
1 parent 612f4c9 commit 7c58be3

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

app/src/processing/app/Editor.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,15 +2124,14 @@ protected void handleOpenUnchecked(File file, int codeIndex,
21242124
* Second stage of open, occurs after having checked to see if the
21252125
* modifications (if any) to the previous sketch need to be saved.
21262126
*/
2127-
protected boolean handleOpenInternal(File file) {
2127+
protected boolean handleOpenInternal(File sketchFile) {
21282128
// check to make sure that this .pde file is
21292129
// in a folder of the same name
2130-
String fileName = file.getName();
2130+
String fileName = sketchFile.getName();
21312131

2132-
if (SketchData.checkSketchFile(file)) {
2133-
// no beef with this guy
2132+
File file = SketchData.checkSketchFile(sketchFile);
21342133

2135-
} else if (!fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
2134+
if ((file == null) && !fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
21362135
Base.showWarning(_("Bad file selected"),
21372136
_("Arduino can only open its own sketches\n" +
21382137
"and other files ending in .ino or .pde"), null);

app/src/processing/app/SketchData.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public int compare(SketchCode x, SketchCode y) {
5252
//System.out.println("sketch dir is " + folder);
5353
}
5454

55-
static public boolean checkSketchFile(File file) {
55+
static public File checkSketchFile(File file) {
5656
// check to make sure that this .pde file is
5757
// in a folder of the same name
5858
String fileName = file.getName();
@@ -63,7 +63,16 @@ static public boolean checkSketchFile(File file) {
6363
String inoName = parentName + ".ino";
6464
File altInoFile = new File(parent, inoName);
6565

66-
return pdeName.equals(fileName) || inoName.equals(fileName) || altPdeFile.exists() || altInoFile.exists();
66+
if (pdeName.equals(fileName) || inoName.equals(fileName))
67+
return file;
68+
69+
if (altPdeFile.exists())
70+
return altPdeFile;
71+
72+
if (altInoFile.exists())
73+
return altInoFile;
74+
75+
return null;
6776
}
6877

6978
/**

app/src/processing/app/debug/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public interface ProgressListener {
8383
private ProgressListener progressListener;
8484

8585
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
86-
if (!SketchData.checkSketchFile(data.getPrimaryFile()))
86+
if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
8787
BaseNoGui.showError(_("Bad file selected"),
8888
_("Bad sketch primary file or bad sketck directory structure"), null);
8989

0 commit comments

Comments
 (0)