diff options
author | Eric Williams | 2018-12-17 20:43:17 +0000 |
---|---|---|
committer | Eric Williams | 2018-12-20 16:46:26 +0000 |
commit | 50c3e60ee63bf15523be8ccc716ff93e0828e94f (patch) | |
tree | f7bb5324628a2932ce6a201eed89289e35809ce5 | |
parent | efd9a47494713d548ce099019b4f5bf810c09707 (diff) | |
download | eclipse.platform.swt-50c3e60ee63bf15523be8ccc716ff93e0828e94f.tar.gz eclipse.platform.swt-50c3e60ee63bf15523be8ccc716ff93e0828e94f.tar.xz eclipse.platform.swt-50c3e60ee63bf15523be8ccc716ff93e0828e94f.zip |
Bug 542865: [GTK4] Snippets with any children of Shell crash upon
gtk_widget_get_surface_allocation()
GTK4 no longer supports "own" surfaces for widgets, so this patch
removes this logic from the GTK4 SwtFixed implementation.
Some adjustments have to made in Control, as we do
gtk_widget_get_has_surface_or_window() checks to determine the
paintHandle. In GTK4 this is broken so always use the surface of the
fixedHandle (or clientHandle in the case of Group).
Change-Id: I09c0c096407ab67ac10edfcd21a3c9927cb5f833
Signed-off-by: Eric Williams <ericwill@redhat.com>
5 files changed, 51 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c index 91ef301f78..d46a299e88 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c @@ -780,7 +780,6 @@ static void swt_fixed_class_init (SwtFixedClass *class) { g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy"); /* Widget implementation */ - widget_class->realize = swt_fixed_realize; widget_class->map = swt_fixed_map; widget_class->measure = swt_fixed_measure; widget_class->size_allocate = swt_fixed_size_allocate; @@ -850,7 +849,7 @@ static void swt_fixed_init (SwtFixed *widget) { priv->hadjustment = NULL; priv->vadjustment = NULL; - gtk_widget_set_has_surface(GTK_WIDGET(widget), TRUE); + gtk_widget_set_has_surface(GTK_WIDGET(widget), FALSE); } static void swt_fixed_finalize (GObject *object) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 58d2ed9f8a..799ee5e0c7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -492,6 +492,7 @@ long /*int*/ topHandle() { long /*int*/ paintHandle () { long /*int*/ topHandle = topHandle (); + if (GTK.GTK4) return topHandle; long /*int*/ paintHandle = handle; while (paintHandle != topHandle) { if (gtk_widget_get_has_surface_or_window (paintHandle)) break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java index 78818cf2d7..6a6653aac2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java @@ -452,6 +452,7 @@ long /*int*/ paintHandle() { if (GTK.GTK_VERSION < OS.VERSION(3, 14, 0)) { return super.paintHandle(); } else { + if (GTK.GTK4) return clientHandle; long /*int*/ topHandle = topHandle (); /* we draw all our children on the clientHandle*/ long /*int*/ paintHandle = clientHandle; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 525397d7ce..d513ffd15f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -816,7 +816,11 @@ void createHandle (int index) { if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES); createHandle (index, false, true); GTK.gtk_container_add (vboxHandle, scrolledHandle); - GTK.gtk_box_set_child_packing (vboxHandle, scrolledHandle, true, true, 0, GTK.GTK_PACK_END); + if (GTK.GTK4) { + GTK.gtk_box_set_child_packing(vboxHandle, scrolledHandle, GTK.GTK_PACK_END); + } else { + GTK.gtk_box_set_child_packing (vboxHandle, scrolledHandle, true, true, 0, GTK.GTK_PACK_END); + } group = GTK.gtk_window_group_new (); if (group == 0) error (SWT.ERROR_NO_HANDLES); /* diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug542865_ShellChildrenCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug542865_ShellChildrenCrash.java new file mode 100644 index 0000000000..3c56a706e0 --- /dev/null +++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug542865_ShellChildrenCrash.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat and others. All rights reserved. + * The contents of this file are made available under the terms + * of the GNU Lesser General Public License (LGPL) Version 2.1 that + * accompanies this distribution (lgpl-v21.txt). The LGPL is also + * available at http://www.gnu.org/licenses/lgpl.html. If the version + * of the LGPL at http://www.gnu.org is different to the version of + * the LGPL accompanying this distribution and there is any conflict + * between the two license versions, the terms of the LGPL accompanying + * this distribution shall govern. + * + * Contributors: + * Red Hat - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.tests.gtk.snippets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.RowLayout; +/* + * example snippet: Hello World + * + * For a list of all SWT example snippets see + * http://www.eclipse.org/swt/snippets/ + */ +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class Bug542865_ShellChildrenCrash { + +public static void main (String [] args) { + Display display = new Display (); + Shell shell = new Shell(display); + shell.setLayout(new RowLayout()); + Button button = new Button (shell, SWT.PUSH); + button.setText("Test push button"); + shell.open (); + while (!shell.isDisposed ()) { + if (!display.readAndDispatch ()) display.sleep (); + } + display.dispose (); +} +} |