Bug 563407

Summary: Icons from disabled CommandContributionItem are invisible
Product: [Eclipse Project] Platform Reporter: Andrey Loskutov <loskutov>
Component: SWTAssignee: Andrey Loskutov <loskutov>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: lshanmug, simeon.danailov.andreev
Version: 4.14Keywords: regression
Target Milestone: 4.16 RC1Flags: lshanmug: review+
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=302918
https://git.eclipse.org/r/163333
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=bafd10404c2982b2b5b5e75b583e4839b54288d6
Whiteboard:
Attachments:
Description Flags
Invisible command button without patch
none
Example project to reproduce none

Description Andrey Loskutov CLA 2020-05-20 12:44:11 EDT
We are observing regression from bug 302918.

We have view with CommandContributionItem's contributed to the toolbar.
Some of them are initially disabled.
Before 4.14 we see "disabled" icons on the toolbar, after update to 4.16 we don't see anything but the buttons *are* there, because there is a tooltip while hovering over them.

I've bisected this to bug 302918 changes. 
The problem here is: 

1) CommandContributionItem creates ToolItem without icon in org.eclipse.ui.menus.CommandContributionItem.fill(ToolBar, int)
2) ToolItem.setEnabled(false) is called from CommandContributionItem.updateToolItem()
3) ToolItem.enabled is now false
4) CommandContributionItem.updateIcons() calls now with non-null icon to ToolItem.setImage(Image)
5) ToolItem.enabled is false, disabledImage is null, so the check below is true and we return without setting the image. 

if (!enabled && disabledImage != image) {
	return;
}

The patch would be to additionally check if the disabled image is not null before refusing to set enabled image:

if (!enabled && disabledImage != image && disabledImage != null) {
	return;
}
setImage(image);

I will provide a patch.
Comment 1 Eclipse Genie CLA 2020-05-20 12:49:13 EDT
New Gerrit change created: https://git.eclipse.org/r/163333
Comment 2 Lakshmi P Shanmugam CLA 2020-05-26 06:54:05 EDT
@Andrey, gerrit already has +1, I think additional vote on bug is not required.
Comment 4 Andrey Loskutov CLA 2020-05-26 10:01:41 EDT
Created attachment 283021 [details]
Invisible command button without patch
Comment 5 Andrey Loskutov CLA 2020-05-26 10:02:12 EDT
Created attachment 283022 [details]
Example project to reproduce
Comment 6 Lakshmi P Shanmugam CLA 2020-05-27 02:23:21 EDT
resolving