Blob Blame History Raw
From 1a375bfbb7dca92b102db09891a18eeb80d671f2 Mon Sep 17 00:00:00 2001
From: Eric Williams
Date: Tue, 19 Jan 2016 15:16:57 -0500
Subject: Bug 486069: [Wayland] NullPointerException in TabFolder when running
 ControlExample

This patch adds a missing logic check to prevent a GtkNotebook from
switching to a page that doesn't exist. Wayland seems to trigger an
early page switch, causing gtk_notebook_get_current_page() to return -1.
This will cause a NullPointerException in TabFolder.gtk_switch_page().

Tested on GTK3.19.6, and 3.18. AllNonBrowser JUnit tests pass on
GTK3.19.6 (with the exception of an unrelated previously failing test
case).

Change-Id: I720a7b08c0b49bebce15951f5d5deb00a2304839
Signed-off-by: Eric Williams <ericwill@redhat.com>---
 .../Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java              | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index 7344bf7..00e157c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java	
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java	
@@ -565,6 +565,8 @@ long /*int*/ gtk_switch_page (long /*int*/ widget, long /*int*/ page, long /*int
 		if (control != null && !control.isDisposed ()) {
 			control.setVisible (false);
 		}
+	} else {
+		return 0;
 	}
 	TabItem item = items [(int)/*64*/page_num];
 	Control control = item.getControl ();
-- 
cgit v0.11.2-4-g4a35