Skip to content

Commit 5d67ce6

Browse files
ptzieglerakurtakov
authored andcommitted
[GTK4] SIGSEGV in OS.gdk_display_get_default() during splash screen
The static initializer in OS is calling "gdk_display_get_default()" via "isX11()" and therefore violates the requirement that "gtk_init()"/"gtk_init_check()" must be invoked before any other GTK+ function. While doing so works in GTK3, it is by no means a documented behavior, but rather something that works by pure chance [1]. With this change, the system property is moved from the initializer to the Display constructor, where the init function is explicitly called. The original change was made in response to an error being thrown while executing the JUnit tests on Wayland [2]. But because the display is created before those are executed, it should be safe to do so at either places. [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=465863 [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=528968
1 parent 58d0538 commit 5d67ce6

File tree

2 files changed

+2
-4
lines changed
  • bundles/org.eclipse.swt
    • Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk
    • Eclipse SWT/gtk/org/eclipse/swt/widgets

2 files changed

+2
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,6 @@ public static String getEnvironmentalVariable (String envVarName) {
687687

688688
System.setProperty("org.eclipse.swt.internal.gtk.version",
689689
(GTK.GTK_VERSION >>> 16) + "." + (GTK.GTK_VERSION >>> 8 & 0xFF) + "." + (GTK.GTK_VERSION & 0xFF));
690-
// set GDK backend if we are on X11
691-
if (isX11()) {
692-
System.setProperty("org.eclipse.swt.internal.gdk.backend", "x11");
693-
}
694690
}
695691

696692
protected static byte [] ascii (String name) {

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ void createDisplay (DeviceData data) {
12041204
themeDark = checkAndSetThemeDetails(themeName);
12051205
if (OS.isX11()) {
12061206
xDisplay = GTK.GTK4 ? 0 : GDK.gdk_x11_get_default_xdisplay();
1207+
// set GDK backend if we are on X11
1208+
System.setProperty("org.eclipse.swt.internal.gdk.backend", "x11");
12071209
}
12081210
if (OS.SWT_DEBUG) Device.DEBUG = true;
12091211
long ptr = GTK.gtk_check_version (GTK3_MAJOR, GTK3_MINOR, GTK3_MICRO);

0 commit comments

Comments
 (0)