Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324321 - in editable combo, typed value change to matching value from list when combo layout is updated
Summary: in editable combo, typed value change to matching value from list when combo ...
Status: CLOSED DUPLICATE of bug 240657
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-02 11:14 EDT by Alain Dupeyron CLA
Modified: 2010-10-12 10:36 EDT (History)
2 users (show)

See Also:


Attachments
test combo case (2.14 KB, text/plain)
2010-09-02 11:16 EDT, Alain Dupeyron CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alain Dupeyron CLA 2010-09-02 11:14:43 EDT
Build Identifier: 20100617-1415

in an editable Combo (not READ_OLNY), set a list of items (ex: "1", "8", "16", "32")
type or set 3 in the combo text, when the combo is repaint by resizing the windows by example, the combo value is changed to value 32 from the given list ? instead of 3.
when binding a model on combo, displayed value is incoherent with model one...



Reproducible: Always

Steps to Reproduce:
1. run the given testCombo initialized with setText("3")
2. at startup 32 is display in combo instead of 3 ?
3. fill again 3 in combo
4. change windows with (or click button "re-layout")
5. 32 is selected again in combo ?
Comment 1 Alain Dupeyron CLA 2010-09-02 11:16:56 EDT
Created attachment 178053 [details]
test combo case
Comment 2 Felipe Heidrich CLA 2010-09-03 10:45:12 EDT
Works for me.

> Steps to Reproduce:
> 1. run the given testCombo initialized with setText("3")
> 2. at startup 32 is display in combo instead of 3 ?

for me, 3 shows

> 3. fill again 3 in combo
> 4. change windows with (or click button "re-layout")
> 5. 32 is selected again in combo ?

for me, it still shows 3 after clicking the "re-layout" button.

Tested on Xp and Windows 7

please, try with the latest version:
http://www.eclipse.org/swt/cvs.php
Comment 3 Penka CLA 2010-09-07 12:25:49 EDT
This same defect occurs in Eclipse 3.6.0, Windows XP, Windows 7. 
Create dialog with editable combo.
In the createDialogArea() method, set the combo items list to items such as {"test1", "test12"}. 
After that use setText() to set the combo value to value that is not in the items list but matches the beginning of an item from the combo; example - "test".
Open the dialog.
The text is set properly. But later when the shell calls layout() and sets the controls size, the combo value will be changed to "test1".
So when the dialog is displayed, the value will be "test1".

This is known issue with Windows combo. In the Combo class there is comment:
/*
	* Feature in Windows.  When an editable drop down combo box
	* contains text that does not correspond to an item in the
	* list, when the widget is resized, it selects the closest
	* match from the list.  The fix is to lock the current text
	* by ignoring all WM_SETTEXT messages during processing of
	* WM_SIZE.
	*/

In the Combo class they use lockText flag to avoid such problems.
I compared the Combo code in Eclipse 3.5.1 and 3.6 an saw that setting lockText is done on one more place in Eclipse 3.6.
----------------
long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
	if (handle == 0) return 0;
	if (hwnd == handle) {
		switch (msg) {
			case OS.WM_SIZE: {
				ignoreResize = true;
				if ((style & SWT.READ_ONLY) == 0) lockText = true;
				long /*int*/ result = OS.CallWindowProc (ComboProc, hwnd, msg, wParam, lParam);
				if ((style & SWT.READ_ONLY) == 0) lockText = false;
				ignoreResize = false;
				return result;
			}
		}
---------------------

My guess is this setting lockText to false there is somehow causing the problem.

This is very annoying problem, because in our RCP we use editable combos that have history and this bug causes false values to show up when the user opens a dialog. One workaround is to add the new value to the combo before using setText(), but it is hard to do it everywhere in the code where combo is used.
Please give some workaround for Eclipse 3.6.
Comment 4 Felipe Heidrich CLA 2010-09-08 16:20:52 EDT
I'm 99.9% sure this problem is already fixed.
I believe it was fixed along with bug 240657 or 277618 or 240657.
As a matter of fact, I was able to see the problem you described by removing the fix for bug 240657.

Please get the code from HEAD and try your code again:
http://www.eclipse.org/swt/cvs.php
Comment 5 Penka CLA 2010-09-10 11:14:26 EDT
(In reply to comment #4)
> I'm 99.9% sure this problem is already fixed.
True. I got the SWT plugins from one of the latest 3.6.1 milestone builds and it is fixed. Sorry about the confusion.
Comment 6 Alain Dupeyron CLA 2010-09-21 09:55:19 EDT
(In reply to comment #5)


sorry I was in vacations... Thanks for the tests !

Is there a workaround for my RCP application still based on Galileo (3.5) ? as installing swt jar of the latest 3.6.1 milestone builds or it's incompatible/risky on Galileo ?

I have to close this bug ?
Comment 7 Felipe Heidrich CLA 2010-10-12 10:36:50 EDT
(In reply to comment #6)
> (In reply to comment #5)
> sorry I was in vacations... Thanks for the tests !
> Is there a workaround for my RCP application still based on Galileo (3.5) ? as
> installing swt jar of the latest 3.6.1 milestone builds or it's
> incompatible/risky on Galileo ?

It would probably work but it is hacky (and unsupported).
The best option is to upgrade your RCP app to 3.6.1.

> I have to close this bug ?

done

*** This bug has been marked as a duplicate of bug 240657 ***