Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326264 - [Preferences] ScaleFieldEditor sets underlying SWT Scale object incorrectly
Summary: [Preferences] ScaleFieldEditor sets underlying SWT Scale object incorrectly
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-27 01:04 EDT by Simon Pope CLA
Modified: 2022-03-03 14:38 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 Simon Pope CLA 2010-09-27 01:04:50 EDT
Build Identifier: 20100617-1415

The ScaleFieldEditor sets the minimum and maximum values incorrectly for the Mac platform. It sets minimum before maximum, ensuring that minimum never moves from the default zero value. I.e.:

    private void updateScale() {
        if (scale != null && !scale.isDisposed()) {
            scale.setMinimum(getMinimum());
            scale.setMaximum(getMaximum());
            scale.setIncrement(getIncrement());
            scale.setPageIncrement(getPageIncrement());
        }
    }

Reproducible: Always

Steps to Reproduce:
It should set the maximum *before* setting the minimum. I.e.:

    private void updateScale() {
        if (scale != null && !scale.isDisposed()) {
            scale.setMaximum(getMaximum());
            scale.setMinimum(getMinimum());
            scale.setIncrement(getIncrement());
            scale.setPageIncrement(getPageIncrement());
        }
    }

This change is needed to make the ScaleFieldEditor work properly on Mac. The other option is to set the minimum, set the maximum, and then check and set the minimum again if it hasn't taken. This though seems pointless.
Comment 1 Simon Pope CLA 2010-09-27 01:08:46 EDT
Note, this is because on the Mac, if the minimum is greater than the maximum, then the minimum is not set. Not sure if this is the correct platform behavior.
Comment 2 Remy Suen CLA 2010-09-27 06:04:09 EDT
Simon, are you using Carbon or Cocoa? Or does the bug appear on both windowing systems?

(In reply to comment #1)
> Note, this is because on the Mac, if the minimum is greater than the maximum,
> then the minimum is not set. Not sure if this is the correct platform behavior.

SWT team, please advise if this is an SWT bug or something enforced by the platform.
Comment 3 Simon Pope CLA 2010-09-27 06:06:42 EDT
Cocoa.

In Scale.setMiniumum(int value) the code reads:

public void setMinimum (int value) {
	checkWidget();
	int maximum = (int)((NSSlider)view).maxValue();
	if (!(0 <= value && value < maximum)) return;
	((NSSlider)view).setMinValue(value);
}

So, if minimum is greater than value, minimum will never be set. Oops. :-)
Comment 4 Simon Pope CLA 2010-09-27 06:43:50 EDT
I meant ... if value is greater than maximum, minimum will never be set to value.
Comment 5 Scott Kovatch CLA 2010-09-27 17:52:25 EDT
How is this different than what we are doing on Win32? The if test is inverted (compared to Cocoa) but the logic appears to be the same.
Comment 6 Simon Pope CLA 2010-09-27 19:32:35 EDT
(In reply to comment #5)
> How is this different than what we are doing on Win32? The if test is inverted
> (compared to Cocoa) but the logic appears to be the same.

Then I guess this is an issue with ScaleFieldEditor and not The Cocoa implementation of Scale– which is what I thought.

So if the logic is the same across platforms, the fix is to set the maximum before the minimum in ScaleFieldEditor.updateScale(). 

Even if it were *not* the case across platforms (and let's suppose for argument that it's not), the logic of setting the upper bound of the Scale first and then setting the lower bound (i.e. creating a wider range first before narrowing it), will still work on these platforms.
Comment 7 Scott Kovatch CLA 2010-09-28 12:27:15 EDT
(In reply to comment #6)

> Then I guess this is an issue with ScaleFieldEditor and not The Cocoa
> implementation of Scale– which is what I thought.
> 
> So if the logic is the same across platforms, the fix is to set the maximum
> before the minimum in ScaleFieldEditor.updateScale(). 

Yep, I agree. Back to platform-ui.
Comment 8 Eclipse Webmaster CLA 2019-09-06 16:09:45 EDT
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.

If you have further information on the current state of the bug, please add it. 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.
Comment 9 Eclipse Genie CLA 2022-03-03 14:38:49 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.