widgets-toolbox icon indicating copy to clipboard operation
widgets-toolbox copied to clipboard

List Selector (two pane) can crash MATLAB due to HighlightedValue being empty in the set method

Open rjackey opened this issue 2 years ago • 3 comments

g3198185 - The error comes from ListSelectorTwoPane.m. The following update is proposed:

    function set.HighlightedValue(obj,value)
        if isempty(value)
            return;
        end
        if isempty(obj.ItemsData)
            [~, obj.RightList.Value] = ismember(value, obj.Items);
        else
            [~, obj.RightList.Value] = ismember(value, obj.ItemsData);
        end
    end

rjackey avatar Jan 08 '24 13:01 rjackey

Question on this change:

Would the following proposal also solve the issue (I cannot reproduce it) and still allow for de-selection of the highlighted value?

function set.HighlightedValue(obj,value)
        if isempty(value)
            obj.RightList.Value = {};
            return;
        end
        if isempty(obj.ItemsData)
            [~, obj.RightList.Value] = ismember(value, obj.Items);
        else
            [~, obj.RightList.Value] = ismember(value, obj.ItemsData);
        end
    end

slootsjj avatar Apr 12 '24 13:04 slootsjj

Yes that's a good idea. Was the right list not getting deselected before? You're welcome to submit a change.

rjackey avatar Apr 12 '24 13:04 rjackey

Currently, the right list is not deselected if HighlightedValue is set to an empty value. I will submit a change to repair this.

slootsjj avatar Apr 17 '24 10:04 slootsjj