bugGNU Octave - Bugs: bug #55668, Variable Editor cannot delete...


bug #55668: Variable Editor cannot delete certain rows and columns in struct classes

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Thu 07 Feb 2019 01:56:01 PM UTC  
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error
Status:  Confirmed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  Open
Release:  5.0.91 Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sat 09 Feb 2019 12:38:13 PM UTC, comment #8:

Funny, I've been using the V.E. for > 4 years, from the time it was still a patch, and never hit these issues. But maybe I did, forgot the issues and intuitively/routinely worked around them ever since :-) But then again, struct support was added relatively recently.
I use the VE about daily, I find it an extremely useful tool for debugging scripts and m-file functions and monitoring workflows.

If there's anything I can do to assist with fixing I'll gladly help (except C++, that's still beyond me).

Philip Nienhuis <philipnienhuis>
Project Member
Fri 08 Feb 2019 10:25:39 PM UTC, comment #7:

@Philip: Your results are all consistent with what I found in the code.

When you try to delete the first fieldname (which is column #1) the generated expression is

Since the struct array is 3x1 this succeeds in erasing the whole thing.

On my system when the struct switches from being a struct_array to a scalar_struct the headings becomes "Values" and the rows become the fieldnames of the struct as expected. If you don't see this immediately it might have something to do with the Qt version that is packaged with MXE Octave.

Rik <rik5>
Project Administrator
Fri 08 Feb 2019 09:17:30 PM UTC, comment #6:

Some more experimenting:

tst = repmat (struct ("a", 1, "b", rand(3)), 3, 1)
openvar tst

Then, right-click column header "b", select "Delete column" => error popup "failed to execute expression 'tst(:, 2:2) = []'". the struct isn't affected.

But if you right-click column header "a", select "Delete column" => all struct contents are wiped, leaving a 3x0 struct behind.

(A cosmetic one)
Again create the struct.
Delete rows one by one. After deleting the last but one row, the row header turn into numbers and the orientation is transposed. After any action, the row headers turn into the expected fieldnames. So maybe there's some callback missing that repaints the row headers.

AFAIK the Variable Editor is still experimental, IOW, not a showstopper for the 5.1 release? Lately I haven't seen the variable editor crash Octave; the original example in bug #53858 works OK, at least on Windows.

Philip Nienhuis <philipnienhuis>
Project Member
Fri 08 Feb 2019 06:18:46 PM UTC, comment #5:

Maybe we need to post something on the Octave Maintainer's list about this. The problem is in the organization of the code and the way the classes interact. The problem is this function

It is a function from variable_editor_model and it assumes that all variables can be deleted given a code sequence

Unfortunately, that is not how fields can be removed from structs. The code would need to use rmfield(). This suggests that the code needs to be organized so that a more specialized class, such as struct_model, could override the default subroutine removeRows. Unfortunately, struct_model is a descendant from base_ve_model which does not define this method. Only variable_editor_model class has this method.

Rik <rik5>
Project Administrator
Fri 08 Feb 2019 05:33:39 PM UTC, comment #4:

Actually, there are some general problems deleting rows and columns in struct classes.


scalar struct
1) cannot delete rows (i.e, fieldnames)
2) cannot delete columns (i.e., variable itself)

vector struct arrays
1) cannot delete columns (i.e, fieldnames)

Rik <rik5>
Project Administrator
Fri 08 Feb 2019 09:24:53 AM UTC, comment #3:

Ah yes I see the very first statement in my report was mixed up, apologies, should have been

tst = repmat (struct ("a", 1, "b", rand(3)), 1, 3)

to have a row struct array.

(I probably got confused when exploring this bug at work due to the large number of trial commands to get a simple test case, just picked a wrong one.)

Philip Nienhuis <philipnienhuis>
Project Member
Thu 07 Feb 2019 05:47:34 PM UTC, comment #2:

Actually, something else must be going on. If I use your exact sequence then the second row is deleted. However, If I try clicking on the column header field and doing "delete column" then no deletion takes place and there is no error/warning.

Rik <rik5>
Project Administrator
Thu 07 Feb 2019 05:40:54 PM UTC, comment #1:

I think you're right about the confusion between row and column.

If you execute this in a command window, it works as expected.


Rik <rik5>
Project Administrator
Thu 07 Feb 2019 01:56:01 PM UTC, original submission:

(Related to bug #55666)
Steps to reproduce:

I think the variable editor is confused because it shows a row array as a column and then gets lost in its own transposed display.

Note that Matlab (up until r2018b, I still want to check it in r2019a prerelease) does exactly the same as regards displaying the row struct array, except it doesn't error when deleting a "row".

One can argue about whether "Delete rows" (Octave) and "Delete row" (Matlab) in this case are accurate as in reality the row structure array is shown as a column and deleting one array entry is essentially deleting a column of a 1xN array rather than a row. In the worst case it could be called "bug for bug compatibility" :-)

Philip Nienhuis <philipnienhuis>
Project Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-08 rik5 Operating SystemMicrosoft Windows => Any
        SummaryVariable Editor cannot delete columns in a row array => Variable Editor cannot delete certain rows and columns in struct classes
    2019-02-07 rik5 StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.4