Bug 563407 - Icons from disabled CommandContributionItem are invisible
Summary: Icons from disabled CommandContributionItem are invisible
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.14   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.16 RC1   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-05-20 12:44 EDT by Andrey Loskutov CLA
Modified: 2020-05-27 02:23 EDT (History)
2 users (show)

See Also:
lshanmug: review+


Attachments
Invisible command button without patch (38.97 KB, image/png)
2020-05-26 10:01 EDT, Andrey Loskutov CLA
no flags Details
Example project to reproduce (14.13 KB, application/zip)
2020-05-26 10:02 EDT, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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