Skip to content

Commit 907238d

Browse files
committed
Stop using the private field internally
1 parent dfd26bb commit 907238d

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

app/src/processing/app/Base.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ public class Base {
130130
// https://github.com/processing/processing/pull/2366
131131
private JFileChooser openChooser;
132132

133-
static protected File sketchbookFolder;
134-
135-
136133
static public void main(final String[] args) {
137134
Messages.log("Starting Processing version" + VERSION_NAME + " revision "+ REVISION);
138135
EventQueue.invokeLater(() -> {
@@ -1951,7 +1948,7 @@ public void populateSketchbookMenu(JMenu menu) {
19511948
new Thread(() -> {
19521949
boolean found = false;
19531950
try {
1954-
found = addSketches(menu, sketchbookFolder);
1951+
found = addSketches(menu, getSketchbookFolder());
19551952
} catch (Exception e) {
19561953
Messages.showWarning("Sketchbook Menu Error",
19571954
"An error occurred while trying to list the sketchbook.", e);
@@ -1990,7 +1987,7 @@ protected boolean addSketches(JMenu menu, File folder) {
19901987
if (folder.getName().equals("sdk")) {
19911988
// This could be Android's SDK folder. Let's double-check:
19921989
File suspectSDKPath = new File(folder.getParent(), folder.getName());
1993-
File expectedSDKPath = new File(sketchbookFolder, "android" + File.separator + "sdk");
1990+
File expectedSDKPath = new File(getSketchbookFolder(), "android" + File.separator + "sdk");
19941991
if (expectedSDKPath.getAbsolutePath().equals(suspectSDKPath.getAbsolutePath())) {
19951992
return false; // Most likely the SDK folder, skip it
19961993
}
@@ -2261,13 +2258,8 @@ static public File getToolsFolder() {
22612258
return Platform.getContentFile("tools");
22622259
}
22632260

2264-
2261+
static protected File sketchbookFolder;
22652262
static public void locateSketchbookFolder() {
2266-
var sketchbookPathOverride = System.getProperty("processing.sketchbook.folder");
2267-
if (sketchbookPathOverride != null && !sketchbookPathOverride.isEmpty()) {
2268-
sketchbookFolder = new File(sketchbookPathOverride);
2269-
return;
2270-
}
22712263
// If a value is at least set, first check to see if the folder exists.
22722264
// If it doesn't, warn the user that the sketchbook folder is being reset.
22732265
String sketchbookPath = Preferences.getSketchbookPath();
@@ -2333,6 +2325,10 @@ static protected void makeSketchbookSubfolders() {
23332325

23342326

23352327
static public File getSketchbookFolder() {
2328+
var sketchbookPathOverride = System.getProperty("processing.sketchbook.folder");
2329+
if (sketchbookPathOverride != null && !sketchbookPathOverride.isEmpty()) {
2330+
return new File(sketchbookPathOverride);
2331+
}
23362332
if (sketchbookFolder == null) {
23372333
locateSketchbookFolder();
23382334
}
@@ -2341,27 +2337,27 @@ static public File getSketchbookFolder() {
23412337

23422338

23432339
static public File getSketchbookLibrariesFolder() {
2344-
return new File(sketchbookFolder, "libraries");
2340+
return new File(getSketchbookFolder(), "libraries");
23452341
}
23462342

23472343

23482344
static public File getSketchbookToolsFolder() {
2349-
return new File(sketchbookFolder, "tools");
2345+
return new File(getSketchbookFolder(), "tools");
23502346
}
23512347

23522348

23532349
static public File getSketchbookModesFolder() {
2354-
return new File(sketchbookFolder, "modes");
2350+
return new File(getSketchbookFolder(), "modes");
23552351
}
23562352

23572353

23582354
static public File getSketchbookExamplesFolder() {
2359-
return new File(sketchbookFolder, "examples");
2355+
return new File(getSketchbookFolder(), "examples");
23602356
}
23612357

23622358

23632359
static public File getSketchbookTemplatesFolder() {
2364-
return new File(sketchbookFolder, "templates");
2360+
return new File(getSketchbookFolder(), "templates");
23652361
}
23662362

23672363

0 commit comments

Comments
 (0)