MCPcopy Index your code
hub / github.com/benfry/processing4 / handleRestart

Method handleRestart

app/src/processing/app/Base.java:1811–1855  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1809
1810
1811 public void handleRestart() {
1812 File app = Platform.getProcessingApp();
1813 System.out.println(app);
1814 if (app.exists()) {
1815 if (handleQuitEach()) { // only if everything saved
1816 SingleInstance.clearRunning();
1817
1818 // Launch on quit
1819 Runtime.getRuntime().addShutdownHook(new Thread(() -> {
1820 try {
1821 //Runtime.getRuntime().exec(app.getAbsolutePath());
1822 System.out.println("launching");
1823 Process p;
1824 if (Platform.isMacOS()) {
1825 p = Runtime.getRuntime().exec(new String[] {
1826 // -n allows more than one instance to be opened at a time
1827 "open", "-n", "-a", app.getAbsolutePath()
1828 });
1829 } else if (Platform.isLinux()) {
1830 p = Runtime.getRuntime().exec(new String[] {
1831 app.getAbsolutePath()
1832 });
1833 } else {
1834 p = Runtime.getRuntime().exec(new String[] {
1835 "cmd", "/c", app.getAbsolutePath()
1836 });
1837 }
1838 System.out.println("launched with result " + p.waitFor());
1839 System.out.flush();
1840 } catch (Exception e) {
1841 e.printStackTrace();
1842 }
1843 }));
1844 handleQuit();
1845 // handleQuit() does not call System.exit() on macOS
1846 if (Platform.isMacOS()) {
1847 System.exit(0);
1848 }
1849 }
1850 } else {
1851 Messages.showWarning("Cannot Restart",
1852 "Cannot automatically restart because the Processing\n" +
1853 "application has been renamed. Please quit and then restart manually.");
1854 }
1855 }
1856
1857
1858 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers

nothing calls this directly

Calls 13

getProcessingAppMethod · 0.95
handleQuitEachMethod · 0.95
clearRunningMethod · 0.95
isMacOSMethod · 0.95
isLinuxMethod · 0.95
handleQuitMethod · 0.95
showWarningMethod · 0.95
execMethod · 0.80
waitForMethod · 0.80
printlnMethod · 0.45
flushMethod · 0.45
printStackTraceMethod · 0.45

Tested by

no test coverage detected