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

Bug 205199

Summary: [Win32]setImage(null) on Label overrides text
Product: [Eclipse Project] Platform Reporter: Fabian Zeindl <fabian.zeindl>
Component: SWTAssignee: Paul Pazderski <paul-eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, grant_gayed, khouly, lshanmug, mfadl, nikita, paul-eclipse, remy.suen
Version: 3.4Keywords: triaged
Target Milestone: 4.13 M1   
Hardware: PC   
OS: Windows All   
See Also: https://git.eclipse.org/r/143312
https://git.eclipse.org/r/143313
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=1ebd136999348eaf6d9839b9b54ef7383ee04db4
Whiteboard:
Bug Depends on:    
Bug Blocks: 548736    
Attachments:
Description Flags
Testcase
none
setImage(null) for GTK and Windows before and after change none

Description Fabian Zeindl CLA 2007-10-02 11:23:43 EDT
Build ID: 3.3

Steps To Reproduce:
1. create a Label on Windows and a Button event for setting a picture on it using setImage. A second klick would set a Text and use setImage(null).
2. the text doesn't appear, only when you do setImage(null) first and _then_ set the text.

More information:
Comment 1 Steve Northover CLA 2007-10-02 12:16:05 EDT
Is there a difference between Windows and Linux?  The correct behavior is that the last thing set (either text or image) is displayed.
Comment 2 Fabian Zeindl CLA 2007-10-02 13:24:42 EDT
Yes. Under Linux/GTK I can set a text and then do setImage(null) so the text is displayed.
Comment 3 Steve Northover CLA 2007-10-02 14:18:16 EDT
Ok, then this is not a bug.  Right now, Label won't display both a text and an image.  Try CLabel for this.
Comment 4 Fabian Zeindl CLA 2007-10-02 14:44:21 EDT
But I don't set an image _and_ a text. I deleted the previously set image with setImage(null).
Comment 5 Steve Northover CLA 2007-10-02 15:43:54 EDT
Please provide a snippet that shows the problem.
Comment 6 Fabian Zeindl CLA 2007-10-04 11:12:23 EDT
Created attachment 79735 [details]
Testcase

Launch the application and click the button three times:

Under Linux, "1. Text", then the image, then "3. Text" is displayed
Under Windows, "1. Text", then the image, then nothing is displayed

I use Ubuntu Feisty (7.04) which means gtk-2.10, swt 3.3 and java6.
Comment 7 Fabian Zeindl CLA 2007-12-04 11:52:39 EST
Any news about this issue?
Comment 8 Fabian Zeindl CLA 2008-02-03 12:05:07 EST
Why? What's the problem with adding it to 3.3.2?
Comment 9 Grant Gayed CLA 2009-08-28 09:54:49 EDT
AM, the gtk behaviour is correct, please fix on win32 and cocoa.
Comment 10 Eric Williams CLA 2016-10-09 11:23:41 EDT
(In reply to Grant Gayed from comment #9)
> AM, the gtk behaviour is correct, please fix on win32 and cocoa.

Moving to Windows.
Comment 11 Eclipse Genie CLA 2019-06-04 18:13:12 EDT
New Gerrit change created: https://git.eclipse.org/r/143312
Comment 12 Paul Pazderski CLA 2019-06-04 18:16:08 EDT
Created attachment 278823 [details]
setImage(null) for GTK and Windows before and after change

Label need to set some static control styles when swapping between text and image rendering but fails in some cases e.g. when setting image to null or resetting same text after image was set.

I attached an image to show the results from different orders of setText/setImage for GTK, Win32 before and after change. From left to right:
 1. setText
 2. setImage
 3. setText -> setImage
 4. setImage -> setText
 5. setText -> setImage -> setText
 6. setImage -> setText -> setImage
 7. setText -> setImage -> setImage(null)
 
The Snippet to create this screenshot is included in the change.
Comment 13 Eclipse Genie CLA 2019-06-04 18:17:26 EDT
New Gerrit change created: https://git.eclipse.org/r/143313
Comment 14 Eric Williams CLA 2019-06-04 22:49:51 EDT
Thanks for the fix Paul. We are currently wrapping up the 4.12 so development is frozen. When master reopens (should happen next week or week after, at the latest) your patches will be reviewed/merged.
Comment 15 Nikita Nemkin CLA 2019-06-05 03:00:47 EDT
The API itself is broken. Either Text and Image should be exclusive (only one non-null at a time), or Image should act as an override (then setText effect is not visible, until Image is removed). As it stands, visual state of the label can't be derived from its properties alone, which is nonsense.
Comment 16 Nikita Nemkin CLA 2019-06-05 03:13:08 EDT
Forgot to add: if we fix Image property to be a proper override (i.e. setText doesn't show text as long as Image is present), then Text can be reused as an accessible description of the image label.
Comment 18 Lakshmi P Shanmugam CLA 2019-06-28 03:22:19 EDT
This is not yet fixed on Cocoa, will clone this bug for Cocoa.
Comment 19 Lakshmi P Shanmugam CLA 2019-07-09 07:54:31 EDT
(In reply to Lakshmi Shanmugam from comment #18)
> This is not yet fixed on Cocoa, will clone this bug for Cocoa.

Done by Bug 548736.
Comment 20 Paul Pazderski CLA 2019-07-10 12:49:20 EDT
Verified with I20190710-0610