diff options
author | Andrey Loskutov | 2015-07-15 13:54:29 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2015-08-10 11:03:34 +0000 |
commit | 84570dc1b48c0ba9e7f3220fae8e28aef46e7b21 (patch) | |
tree | 888df10a645cddca3e6b3585009cd535ed3fd379 /bundles | |
parent | 53e7bf726b7dff67545f4eea5dade45d374c80af (diff) | |
download | eclipse.platform.swt-84570dc1b48c0ba9e7f3220fae8e28aef46e7b21.tar.gz eclipse.platform.swt-84570dc1b48c0ba9e7f3220fae8e28aef46e7b21.tar.xz eclipse.platform.swt-84570dc1b48c0ba9e7f3220fae8e28aef46e7b21.zip |
Bug 472743 - [GTK2] Shell.setBounds() with specific values crashes JVM
Added workaround: allow max width/height in setBounds() to be only 2^14
- 1.
Change-Id: I3127af3dfeefe6784bc8eb9bf5ad8be034612ef2
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java | 34 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 10 |
2 files changed, 36 insertions, 8 deletions
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 8f5fe71daa..47b1002a28 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 @@ -848,6 +848,11 @@ public Rectangle getBounds () { * receiver to a negative number will cause that * value to be set to zero instead. * </p> + *<p> + * Note: Attempting to set the width or height of the + * receiver to a number higher or equal 2^14 will cause them to be + * set to (2^14)-1 instead. + * </p> * * @param rect the new bounds for the receiver * @@ -874,6 +879,11 @@ public void setBounds (Rectangle rect) { * receiver to a negative number will cause that * value to be set to zero instead. * </p> + *<p> + * Note: Attempting to set the width or height of the + * receiver to a number higher or equal 2^14 will cause them to be + * set to (2^14)-1 instead. + * </p> * * @param x the new x coordinate for the receiver * @param y the new y coordinate for the receiver @@ -942,6 +952,10 @@ void resizeHandle (int width, int height) { } int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { + // bug in GTK2 crashes JVM, in GTK3 the new shell only. See bug 472743 + width = Math.min(width, (2 << 14) - 1); + height = Math.min(height, (2 << 14) - 1); + long /*int*/ topHandle = topHandle (); boolean sendMove = move; GtkAllocation allocation = new GtkAllocation (); @@ -1153,6 +1167,11 @@ public Point getSize () { * receiver to a negative number will cause them to be * set to zero instead. * </p> + *<p> + * Note: Attempting to set the width or height of the + * receiver to a number higher or equal 2^14 will cause them to be + * set to (2^14)-1 instead. + * </p> * * @param size the new size for the receiver * @@ -1227,6 +1246,11 @@ void setRelations () { * receiver to a negative number will cause that * value to be set to zero instead. * </p> + *<p> + * Note: Attempting to set the width or height of the + * receiver to a number higher or equal 2^14 will cause them to be + * set to (2^14)-1 instead. + * </p> * * @param width the new width for the receiver * @param height the new height for the receiver @@ -2836,8 +2860,8 @@ public Monitor getMonitor () { long /*int*/ screen = OS.gdk_screen_get_default (); if (screen != 0) { int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ()); - Monitor[] monitors = display.getMonitors (); - + Monitor[] monitors = display.getMonitors (); + if (monitorNumber >= 0 && monitorNumber < monitors.length) { return monitors [monitorNumber]; } @@ -3108,7 +3132,7 @@ long /*int*/ gtk_enter_notify_event (long /*int*/ widget, long /*int*/ event) { } long /*int*/ toolHandle = getShell().handle; OS.gtk_widget_set_tooltip_text (toolHandle, buffer); - + if (display.currentControl == this) return 0; GdkEventCrossing gdkEvent = new GdkEventCrossing (); OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof); @@ -4768,7 +4792,7 @@ boolean setTabItemFocus (boolean next) { /** * Sets the base text direction (a.k.a. "paragraph direction") of the receiver, * which must be one of the constants <code>SWT.LEFT_TO_RIGHT</code>, - * <code>SWT.RIGHT_TO_LEFT</code>, or a bitwise disjunction + * <code>SWT.RIGHT_TO_LEFT</code>, or a bitwise disjunction * <code>SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT</code>. The latter stands for an * "auto" direction, which implies that a control containing text derives the * direction from the directionality of the first strong bidi character. @@ -5527,7 +5551,7 @@ void update (boolean all, boolean flush) { long /*int*/ window = paintWindow (); if (flush) display.flushExposes (window, all); /* - * Do not send expose events on GTK 3.16.0+ + * Do not send expose events on GTK 3.16.0+ * It's worth checking whether can be removed on all GTK 3 versions. */ if (OS.GTK_VERSION < OS.VERSION(3, 16, 0)) { 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 03d8e40941..43475a3853 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 @@ -698,7 +698,7 @@ void createHandle (int index) { OS.gtk_window_set_transient_for (shellHandle, parent.topHandle ()); OS.gtk_window_set_destroy_with_parent (shellHandle, true); OS.gtk_window_set_skip_taskbar_hint(shellHandle, true); - + /* * For systems running Metacity, by applying the dialog type hint * to a window only the close button can be placed on the title bar. @@ -1256,7 +1256,7 @@ long /*int*/ gtk_configure_event (long /*int*/ widget, long /*int*/ event) { if (!isVisible ()) { return 0; //We shouldn't handle move/resize events if shell is hidden. } - + if (!moved || oldX != x [0] || oldY != y [0]) { moved = true; oldX = x [0]; @@ -1810,6 +1810,10 @@ void resizeBounds (int width, int height, boolean notify) { @Override int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { + // bug in GTK2 crashes JVM, in GTK3 the new shell only. See bug 472743 + width = Math.min(width, (2 << 14) - 1); + height = Math.min(height, (2 << 14) - 1); + if (fullScreen) setFullScreen (false); /* * Bug in GTK. When either of the location or size of @@ -2244,7 +2248,7 @@ public void setText (String string) { @Override public void setVisible (boolean visible) { checkWidget(); - + if (moved) { //fix shell location if it was moved. setLocation(oldX, oldY); } |