MCPcopy
hub / github.com/arduino/Arduino / restoreSketches

Method restoreSketches

app/src/processing/app/Base.java:530–557  ·  view source on GitHub ↗

Post-constructor setup for the editor area. Loads the last sketch that was used (if any), and restores other Editor settings. The complement to "storePreferences", this is called when the application is first launched. @throws Exception

()

Source from the content-addressed store, hash-verified

528 * @throws Exception
529 */
530 protected boolean restoreSketches() throws Exception {
531 // Iterate through all sketches that were open last time p5 was running.
532 // If !windowPositionValid, then ignore the coordinates found for each.
533
534 // Save the sketch path and window placement for each open sketch
535 int count = PreferencesData.getInteger("last.sketch.count");
536 int opened = 0;
537 for (int i = count - 1; i >= 0; i--) {
538 String path = PreferencesData.get("last.sketch" + i + ".path");
539 if (path == null) {
540 continue;
541 }
542 if (BaseNoGui.getPortableFolder() != null && !new File(path).isAbsolute()) {
543 File absolute = new File(BaseNoGui.getPortableFolder(), path);
544 try {
545 path = absolute.getCanonicalPath();
546 } catch (IOException e) {
547 // path unchanged.
548 }
549 }
550 int[] location = retrieveSketchLocation("" + i);
551 // If file did not exist, null will be returned for the Editor
552 if (handleOpen(new File(path), location, nextEditorLocation(), false, false) != null) {
553 opened++;
554 }
555 }
556 return (opened > 0);
557 }
558
559 /**
560 * Store screen dimensions on last close

Callers 1

BaseMethod · 0.95

Calls 6

getIntegerMethod · 0.95
getMethod · 0.95
getPortableFolderMethod · 0.95
handleOpenMethod · 0.95
nextEditorLocationMethod · 0.95

Tested by

no test coverage detected