Bug 520217 - [Win32] Button's disabled-image gets incorrectly drawn on SWT Resize
Summary: [Win32] Button's disabled-image gets incorrectly drawn on SWT Resize
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-07-26 10:49 EDT by Michael Haywood CLA
Modified: 2020-02-15 20:29 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Haywood CLA 2017-07-26 10:49:38 EDT
I've been using SWT and have found an issue.

When selecting and deselecting check boxes and maximizing the window it will cause the icon of the first button to be set even though it is null. Also the layout of the text on the buttons can end up incorrect.

To recreate the error:

Select checkbox 1
Deselect checkbox 1
Select checkbox 3
Maximize the window
The icon for checkbox 1 should be null (empty) but instead it has the cross icon.


 public static void main(String[] args) {
       final Display d = new Display();
       Shell s = new Shell(d);
       s.setLayout(new GridLayout(2, false));
       s.setSize(500, 500);

       new Label(s, SWT.NONE).setText("C");
       final Button c = new Button(s, SWT.CHECK);

       new Label(s, SWT.NONE).setText("L1");
       final Button b = new Button(s, SWT.PUSH | SWT.FLAT);
       b.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
       b.setText("Button 1");
       b.setEnabled(false);

       new Label(s, SWT.NONE).setText("C2");
       final Button c2 = new Button(s, SWT.CHECK);

       new Label(s, SWT.NONE).setText("L2");
       final Button b2 = new Button(s, SWT.PUSH | SWT.FLAT);
       b2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
       b2.setImage(null);
       b2.setText("Button 2");
       b2.setEnabled(false);

       new Label(s, SWT.NONE).setText("C3");
       final Button c3 = new Button(s, SWT.CHECK);

       new Label(s, SWT.NONE).setText("L3");
       final Button b3 = new Button(s, SWT.PUSH | SWT.FLAT);
       b3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
       b3.setText("Button 3");
       b3.setEnabled(false);

       c.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
               if (!b.isEnabled()) {
                   b.setImage(d.getSystemImage(SWT.ICON_ERROR));
                   b.setEnabled(true);
               } else {
                   b.setImage(null);
                   b.setEnabled(false);
               }
           }
       });

       c2.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
               if (!b2.isEnabled()) {
                   b2.setImage(d.getSystemImage(SWT.ICON_ERROR));
                   b2.setEnabled(true);
               } else {
                   b2.setImage(null);
                   b2.setEnabled(false);
               }
           }
       });

       c3.addSelectionListener(new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
               if (!b3.isEnabled()) {
                   b3.setImage(d.getSystemImage(SWT.ICON_ERROR));
                   b3.setEnabled(true);
               } else {
                   b3.setImage(null);
                   b3.setEnabled(false);
               }
           }
       });

       s.open();
       while (!s.isDisposed()) {
           if (!d.readAndDispatch())
               d.sleep();
       }
       d.dispose();
   }
Comment 1 Michael Haywood CLA 2017-07-26 10:51:17 EDT
Stack overflow question.

https://stackoverflow.com/questions/45308920/swt-resize-error
Comment 2 Eclipse Genie CLA 2020-02-15 20:29:50 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.