()
| 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 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
nothing calls this directly
no test coverage detected