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

Bug 317545

Summary: [widgets] Text label no longer editable after cancel edit via escape key
Product: [Eclipse Project] Platform Reporter: E. Waldin <earl.waldin>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: skovatch
Version: 3.5.2   
Target Milestone: 3.6   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Stack trace of null pointer exception location none

Description E. Waldin CLA 2010-06-22 03:37:46 EDT
Build Identifier: 20100218-1602

If you edit a text label via direct edit and cancel by using the escape key,
that label can no longer be edited. Neither clicking in the label nor using F2
will enable direct edit for that label.

Reproducible: Sometimes

Steps to Reproduce:
The Galileo Modeling SR2 download can reproduce this problem. Use the geoshapes example that comes with GMF.
Create a shape on a diagram with a label (e.g., an oval with label "abc").
Click select the label to enter direct edit mode. Press the escape key to
cancel the edit and exit direct edit mode. The label can no longer be edited
via direct selection or using F2.

This problem happens 95% of the time when I use my GMF-based diagram. But the
geoshapes example is the easiest way for someone else to reproduce it.

In the geoshapes example, the problem doesn't happen every time, but for some
reason, having a short label of 2-3 characters and using an oval make it happen
more often, at least for me.

The problem appears to be a null pointer exception in SWT's Display class that
occurs as a result of the call getCellEditor().dispose() in method bringDown on
line 115 of DirectEditManager. The NPE occurs in the method fieldEditorProc in
class Display on the line

 return widget.shouldChangeTextInRange_replacementString(id, sel, arg0, arg1) ?
1 : 0;

The variable "widget" is null.

The only workaround is to save, close and re-open the diagram.

The problem also occurs when using GMF's logic example with a note. It does not
happen if I use GEF's logic example, although both go through the same logic in
class DirectEditManager. GMF has its own TextDirectEditManager and
TextCellEditorEx class, so it may be the way GMF interacts with SWT.

I can't reproduce the problem on Windows, so it appears to be Mac only for now.

I'm running Mac OSX Snowleopard on a 64 bit Mac.
Comment 1 E. Waldin CLA 2010-06-22 03:40:42 EDT
Created attachment 172389 [details]
Stack trace of null pointer exception location
Comment 2 E. Waldin CLA 2010-06-22 03:42:27 EDT
I've done some preliminary testing with Helios RC4 and the problem has not yet occurred. So something has changed between Galileo SR2 and Helios.
Comment 3 Scott Kovatch CLA 2010-06-22 12:22:45 EDT
It's hard to say what exactly changed to fix the problem. 3.5.2 to 3.6 RC 4 was a pretty long time -- could have been SWT or GEF. Bug 259181 removed Display.fieldEditorProc, so it's possible that it was fixed as a side effect of that.
Comment 4 Lakshmi P Shanmugam CLA 2017-07-04 05:19:24 EDT
(In reply to E. Waldin from comment #2)
> I've done some preliminary testing with Helios RC4 and the problem has not
> yet occurred. So something has changed between Galileo SR2 and Helios.
According to above comment, problem is fixed in Helios (3.6).