Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328173

Summary: core dump in OS._GTK_WIDGET_UNSET_FLAGS
Product: [Eclipse Project] Platform Reporter: Paul Webster <pwebster>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: akurtakov, eclipse.felipe, emoffatt, remy.suen, Silenio_Quarti
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
java core
none
patch none

Description Paul Webster CLA 2010-10-19 15:26:41 EDT
Created attachment 181217 [details]
java core

Using java version "1.6.0"
Java(TM) SE Runtime Environment (build pxi3260sr8-20100409_01(SR8))

I bring up our 4.1 SDK, and switch from the Breakpoints view to the Variables view and I get the attached core dump.

I haven't yet found a workaround.

PW
Comment 1 Paul Webster CLA 2010-10-19 15:27:36 EDT
This is using:
org.eclipse.swt_3.7.0.v3710.jar
org.eclipse.swt.gtk.linux.x86_3.7.0.v3710.jar

PW
Comment 2 Felipe Heidrich CLA 2010-10-19 16:38:43 EDT
Here is the code:
boolean setFocus () {
	if ((style & SWT.SEPARATOR) != 0) return false;
	if (!OS.gtk_widget_get_child_visible (handle)) return false;
	OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
	OS.gtk_widget_grab_focus (handle);
	boolean result = OS.gtk_widget_is_focus (handle);
	if (!result) OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
	return result;
}


I'm suppose application code is running when gtk_widget_grab_focus () is called (focus in/out event) and it is dispose the toolitem.
The fix should be simple, I'll try the reproduce the problem.
Comment 3 Felipe Heidrich CLA 2010-10-20 11:25:07 EDT
Works for me on 
Version: 4.1.0
Build id: I20101014-1937
running no Linux Fedora 11
Comment 4 Felipe Heidrich CLA 2010-10-20 11:32:44 EDT
This testcase simulates what I think the bug in E4 is, run the snippet and press tab


import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class PR328173 {
	public static void main (String[] args) {
		Display display= new Display();
	    Shell shell= new Shell(display);
	    shell.setLayout(new GridLayout(1, false));
	    final Button button = new Button(shell, SWT.PUSH);
	    button.setText("button");
	    ToolBar bar = new ToolBar (shell,SWT.NONE);
	    final ToolItem item0 = new ToolItem(bar, SWT.PUSH);
	    item0.setText("item0");
	    ToolItem item1 = new ToolItem(bar, SWT.PUSH);
	    item1.setText("item1");
	    display.addFilter(SWT.FocusIn, new Listener() {
			public void handleEvent(Event e) {
				System.out.println("focus in " + e.widget);
			}
		});
	    display.addFilter(SWT.FocusOut, new Listener() {
			public void handleEvent(Event e) {
				System.out.println("focus out " + e.widget);
				if (e.widget == button) item0.dispose();
			}
		});
	    
	    shell.pack();
	    shell.open();
	    while (!shell.isDisposed()) {
	    	if (!display.readAndDispatch())
	    		display.sleep();
	    }
	    display.dispose();
	}
}
Comment 5 Felipe Heidrich CLA 2010-10-20 12:07:45 EDT
Created attachment 181308 [details]
patch
Comment 6 Felipe Heidrich CLA 2010-10-20 12:14:06 EDT
I fixed the crash (code released in HEAD).
That said, GTK doesn't like that we release the widget that is receiving focus during gtk_widget_grab_focus() and prints our several warnings.

I can silence the warnings using Device.setWarnings(false) before calling gtk_widget_grab_focus().


Silenio, does that make sense to you ?
Comment 7 Alexander Kurtakov CLA 2016-12-21 09:15:38 EST
Code has been released years ago. Resolving.