Community
Participate
Working Groups
Executing the snippet given below, typing any character to issue an SWT.Verify event, one can observe the following console output on GTK (Ubuntu 10.04 LTS): focus gained FocusEvent{Text {} time=211143 data=null} verify: Event {type=25 Text {} time=212689 data=null x=0 y=0 width=0 height=0 detail=0} focus lost FocusEvent{Text {} time=212689 data=null} (SWT:1510): Gtk-CRITICAL **: gtk_editable_get_selection_bounds: assertion `GTK_IS_EDITABLE (editable)' failed (SWT:1510): GLib-GObject-WARNING **: invalid (NULL) pointer instance (SWT:1510): GLib-GObject-CRITICAL **: g_signal_stop_emission_by_name: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed On Windows XP and Mac Cocoa the snippet executes with no problem and delivers the following console output: focus gained FocusEvent{Text {} time=131471052 data=null} verify: Event {type=25 Text {} time=131472551 data=null x=0 y=0 width=0 height=0 detail=0} focus lost FocusEvent{Text {} time=131472551 data=null} org.eclipse.swt.widgets.Display@7b479feb Here is the snippet to reproduce: import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.layout.GridLayout; 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.Text; public class Snippet { public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(); shell.setLayout(new GridLayout()); final Text text = new Text(shell, SWT.SINGLE); text.addListener(SWT.Verify, new Listener() { public void handleEvent(Event event) { System.out.println("verify: " + event); text.setVisible(false); text.dispose(); } }); text.addFocusListener(new FocusListener() { public void focusLost(FocusEvent e) { System.out.println("focus lost " + e); System.out.println(text.getDisplay()); } public void focusGained(FocusEvent e) { System.out.println("focus gained " + e); } }); shell.setSize(300, 300); shell.open(); text.setFocus(); while (!shell.isDisposed()) { while (!display.readAndDispatch()) { display.sleep(); } } } } I ran into this when trying to investigate the SWT issue behind bug #318959, which seems to be causes by a similar problem (the listener receives an SWT.Verify event after the Text widget has already be disposed).
New Gerrit change created: https://git.eclipse.org/r/113467
Gerrit change https://git.eclipse.org/r/113467 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=c97f6188dcc940900ebad15d1d088d9d64031802
Really slow fix but better late than never, right?