bugGNU Octave - Bugs: bug #41931, listdlg returns Java object int[]...

 
 

bug #41931: listdlg returns Java object int[] rather than an integer

Submitted by:  Rik <rik5>
Submitted on:  Sat 22 Mar 2014 04:05:12 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.8.1Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sat 22 Mar 2014 07:07:45 PM UTC, comment #2:

I modified the patch to also return an empty matrix, rather than an empty cell list, if the listdlg fails. This matches Matlab behavior. I checked in the changeset on the stable branch (http://hg.savannah.gnu.org/hgweb/octave/rev/51a0d1c1023c).

Rik <rik5>
Project Administrator
Sat 22 Mar 2014 03:09:49 PM UTC, comment #1:

This goes back to at least OF Java package 1.2.8

With octave-3.4.3 & 3.6.4 (both MinGW):
octave:1> [sel, ok] = listdlg ("Liststring", {"One", "Two", "Three"})
...<selecting "Two", clicking OK>
sel =

<Java object: int[]>

ok = 1
octave:2> {"One", "Two", "Three"}(sel(1))
ans =
{
[1,1] = Two
}
octave:3> numel (sel)
ans = 1
octave:4> [sel, ok] = listdlg ("ListString", {"One", "Two", "Three"}, "SelectionMode", "Multiple")
...<selecting "One" and "Three", clicking OK>
sel =

<Java object: int[]>

ok = 1
octave:5> numel (sel)
ans = 2
octave:6> {"One", "Two", "Three"}(sel(1))
ans =
{
[1,1] = One
}
octave:7> {"One", "Two", "Three"}(sel(2))
ans =
{
[1,1] = Three
}
-verbatim-

It isn't straightforward to cast (box) sel into an Octave class:

but as sel can be used for indexing, something along the lines of:
tmp = zeros (numel (sel))
for ii=1:numel (sel)
tmp(ii) = sel(ii);
endfor

gives the desired pointers into ListString.

BTW, the example in listdlg.m isn't at variance with the the bug report and the above observations. Nowhere is it literally stated that sel is an Octave integer. But obviously that is what unwary users would expect.

Another observation:
The actual listing of "One Two Three" doesn't appear on screen unless ListString is in camelcase; IOW the list of choices is empty. Similar holds for other key names.
I'd rather prefer case-insensitive key names. Easily done by morphing the strcmp calls into strcmpi.

Changeset attached for both "issues"

(file #31005)

Philip Nienhuis <philipnienhuis>
Project Member
Sat 22 Mar 2014 04:05:12 AM UTC, original submission:

listdlg, when running in cli-mode, executes Java code to display a list. It is supposed to return an integer which is the 1-based index of the item selected. Instead, it is returning an actual Java Object.

Rik <rik5>
Project Administrator

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #31005:  listdlg_41931.cs added by philipnienhuis (2KiB - text/x-csharp)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 22 Mar 2014 07:07:45 PM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sat 22 Mar 2014 03:10:56 PM UTCphilipnienhuisStatusNone=>Patch Submitted
    Sat 22 Mar 2014 03:09:49 PM UTCphilipnienhuisAttached File-=>Added listdlg_41931.cs, #31005

    Back to the top


    Powered by Savane 3.1-cleanup1