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

Bug 318830

Summary: Text.setText fails during FocusOut event listener (SWT.SINGLE, and when followed by access to the Text)
Product: [Eclipse Project] Platform Reporter: Doug M <eclipse>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: major    
Priority: P3 CC: mail, skovatch
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Demonstrates bug. See steps to reproduce. none

Description Doug M CLA 2010-07-04 22:29:57 EDT
Build Identifier: swt-I20100608-0911-cocoa-macosx-x86_64

When setText is done in a FocusOut event listener, it sometimes fails to change the Text. This happens when setText is followed by getCharCount, computeSize, getText, and possibly any method that accesses the Text content. 

If the FocusOut event is caused by switching to a different application (rather than to a different widget), setText works. If setText is NOT followed by another Text method, it works.

I have traced setText and getText down to NSCell.setTitle(NSString) and NSCell.title(). The NSCell is the same in both calls. However, when setText fails, the NSString returned by title() is the unchanged value, not the value just set with setTitle(string).

Sample snippet contains two Texts. On FocusIn the first Text is set to "Hello"; on FocusOut to "Goodbye". Clicking to the second Text demonstrates that setText fails to change the area's content. Commenting out subsequent access to the Text, or losing focus by app switch shows the that setText succeeds in changing the content.

I am rating as a major bug because it prevents implementing an auto-complete text field that is essential to our project.

Reproducible: Always

Steps to Reproduce:
1. Run the example.
2. See that clicking to the second Text does not change the first one, but switching apps does.
3. Remove call to getCharCount() in the FocusOut listener.
4. See that setText now succeeds in both situations.
Comment 1 Doug M CLA 2010-07-04 22:33:23 EDT
Created attachment 173387 [details]
Demonstrates bug. See steps to reproduce.
Comment 2 Scott Kovatch CLA 2010-07-06 13:11:14 EDT
That's a good bug -- I'll see what I can do for 3.6.1.
Comment 3 Scott Kovatch CLA 2010-09-01 14:22:12 EDT
*** Bug 324056 has been marked as a duplicate of this bug. ***
Comment 4 Scott Kovatch CLA 2010-09-01 17:57:44 EDT
Looks like I can fix this by setting the string into the fieldEditor if one is returned. Looks like multiple Verify events aren't being sent so it looks good.
Comment 5 Scott Kovatch CLA 2010-09-01 18:27:04 EDT
Fixed > 20100901.