Skip to content

Commit 367a0a6

Browse files
committed
[Gtk4] Prevent rare crash in Shell.setVisible
A *_MODAL shells with fullscreen parent was calling removed Gtk 3 function causing a crash with Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.eclipse.swt.internal.gtk3.GTK3.gtk_window_set_type_hint(long, int)' . Simplified snippet to reproduce: ```java Shell shell = new Shell(display); shell.setText("Snippet 1"); shell.setFullScreen(true); shell.open (); Shell shell2 = new Shell(shell, SWT.PRIMARY_MODAL); shell2.setText("Child"); shell2.open(); ```
1 parent 7a6857b commit 367a0a6

File tree

1 file changed

+8
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,14 @@ public void setVisible (boolean visible) {
29092909
* up in front of the full-screen window.
29102910
*/
29112911
if (parent!=null && parent.getShell().getFullScreen()) {
2912-
GTK3.gtk_window_set_type_hint(shellHandle, GDK.GDK_WINDOW_TYPE_HINT_DIALOG);
2912+
if (GTK.GTK4) {
2913+
GTK.gtk_window_set_modal(shellHandle, true);
2914+
GTK.gtk_window_set_transient_for(shellHandle, parent.getShell().shellHandle);
2915+
GTK.gtk_window_set_destroy_with_parent(shellHandle, true);
2916+
} else {
2917+
GTK3.gtk_window_set_type_hint(shellHandle, GDK.GDK_WINDOW_TYPE_HINT_DIALOG);
2918+
2919+
}
29132920
}
29142921
} else {
29152922
updateModal ();

0 commit comments

Comments
 (0)