Skip to content

Commit 9903051

Browse files
authored
Merge pull request #1037 from Stefterv/fix-sketchbook-scanning
Move populateSketchbookMenu to a separate thread
2 parents 6f5e5ba + c86a162 commit 9903051

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

app/src/processing/app/Base.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,18 +1956,20 @@ public void rebuildSketchbook() {
19561956

19571957

19581958
public void populateSketchbookMenu(JMenu menu) {
1959-
boolean found = false;
1960-
try {
1961-
found = addSketches(menu, sketchbookFolder);
1962-
} catch (Exception e) {
1963-
Messages.showWarning("Sketchbook Menu Error",
1964-
"An error occurred while trying to list the sketchbook.", e);
1965-
}
1966-
if (!found) {
1967-
JMenuItem empty = new JMenuItem(Language.text("menu.file.sketchbook.empty"));
1968-
empty.setEnabled(false);
1969-
menu.add(empty);
1970-
}
1959+
new Thread(() -> {
1960+
boolean found = false;
1961+
try {
1962+
found = addSketches(menu, sketchbookFolder);
1963+
} catch (Exception e) {
1964+
Messages.showWarning("Sketchbook Menu Error",
1965+
"An error occurred while trying to list the sketchbook.", e);
1966+
}
1967+
if (!found) {
1968+
JMenuItem empty = new JMenuItem(Language.text("menu.file.sketchbook.empty"));
1969+
empty.setEnabled(false);
1970+
menu.add(empty);
1971+
}
1972+
}).start();
19711973
}
19721974

19731975

@@ -1978,11 +1980,17 @@ public void populateSketchbookMenu(JMenu menu) {
19781980
* sketch should open in a new window.
19791981
*/
19801982
protected boolean addSketches(JMenu menu, File folder) {
1983+
Messages.log("scanning " + folder.getAbsolutePath());
19811984
// skip .DS_Store files, etc. (this shouldn't actually be necessary)
19821985
if (!folder.isDirectory()) {
19831986
return false;
19841987
}
19851988

1989+
// Don't look inside the 'android' folders in the sketchbook
1990+
if (folder.getName().equals("android")) {
1991+
return false;
1992+
}
1993+
19861994
if (folder.getName().equals("libraries")) {
19871995
return false; // let's not go there
19881996
}
@@ -2068,13 +2076,19 @@ protected boolean addSketches(JMenu menu, File folder) {
20682076
*/
20692077
public boolean addSketches(DefaultMutableTreeNode node, File folder,
20702078
boolean examples) throws IOException {
2079+
Messages.log("scanning " + folder.getAbsolutePath());
20712080
// skip .DS_Store files, etc. (this shouldn't actually be necessary)
20722081
if (!folder.isDirectory()) {
20732082
return false;
20742083
}
20752084

20762085
final String folderName = folder.getName();
20772086

2087+
// Don't look inside the 'android' folders in the sketchbook
2088+
if (folderName.equals("android")) {
2089+
return false;
2090+
}
2091+
20782092
// Don't look inside the 'libraries' folders in the sketchbook
20792093
if (folderName.equals("libraries")) {
20802094
return false;

0 commit comments

Comments
 (0)