Skip to content

Commit 8e59cae

Browse files
#10: fixed linux startup hang (javafx is loaded by demand).
1 parent a437a25 commit 8e59cae

File tree

2 files changed

+15
-13
lines changed
  • source/phasereditor

2 files changed

+15
-13
lines changed

source/phasereditor/phasereditor.canvas.ui/src/phasereditor/canvas/ui/CanvasUI.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import com.subshell.snippets.jface.tooltip.tooltipsupport.TreeViewerInformationProvider;
7373

7474
import javafx.embed.swing.SwingFXUtils;
75+
import javafx.embed.swt.FXCanvas;
7576
import javafx.geometry.Bounds;
7677
import javafx.geometry.Insets;
7778
import javafx.geometry.Rectangle2D;
@@ -122,6 +123,7 @@
122123
public class CanvasUI {
123124
private static final int CANVAS_SCREENSHOT_SIZE = 256;
124125
public static final String PLUGIN_ID = "phasereditor.canvas.ui";
126+
private static boolean _fxStarted = false;
125127

126128
public static void logError(Exception e) {
127129
StatusManager.getManager().handle(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e));
@@ -436,6 +438,19 @@ public static Path getCanvasScreenshotFile(IFile file, boolean makeIfNotExist) {
436438
}
437439

438440
public static javafx.scene.image.Image makeCanvasScreenshot_FXImage(IFile file, int maxSize) {
441+
442+
if (!_fxStarted) {
443+
Display.getDefault().syncExec(new Runnable() {
444+
445+
@SuppressWarnings("unused")
446+
@Override
447+
public void run() {
448+
new FXCanvas(new Shell(Display.getDefault()), 0);
449+
}
450+
});
451+
_fxStarted = true;
452+
}
453+
439454
javafx.scene.image.Image[] result = new javafx.scene.image.Image[1];
440455

441456
try (InputStream contents = file.getContents()) {

source/phasereditor/phasereditor.ide/src/phasereditor/ide/intro/PhaserIDE.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
package phasereditor.ide.intro;
2323

24-
import static java.lang.System.out;
25-
2624
import java.io.File;
2725
import java.io.FileInputStream;
2826
import java.io.FileOutputStream;
@@ -60,7 +58,6 @@
6058
import org.osgi.framework.Bundle;
6159
import org.osgi.framework.Version;
6260

63-
import javafx.embed.swt.FXCanvas;
6461
import phasereditor.lic.LicCore;
6562

6663
/**
@@ -136,16 +133,6 @@ public Object start(IApplicationContext appContext) throws Exception {
136133

137134
Display display = createDisplay();
138135

139-
{
140-
// init javafx
141-
out.print("Starting JavaFX runtime...");
142-
Shell shell = new Shell(display);
143-
FXCanvas canvas = new FXCanvas(shell, 0);
144-
canvas.dispose();
145-
shell.dispose();
146-
out.println("done");
147-
}
148-
149136
// processor must be created before we start event loop
150137
DelayedEventsProcessor processor = new DelayedEventsProcessor(display);
151138

0 commit comments

Comments
 (0)