bugGNU Octave - Bugs: bug #41588, findobj() wrongly processes '-not'

 
 

bug #41588: findobj() wrongly processes '-not'

Submitter:  sergey plotnikov <nul0m>
Submitted:  Fri 14 Feb 2014 03:50:25 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 21 Feb 2014 04:42:59 PM UTC, comment #5: 

I made a few modifications to the patch.

Octave coding conventions follow C/C++ and we put parentheses around the test condition in an if statement.


if (condition tested)
   ...
endif


I also went with true/false rather than 1/0.  Either would work but it seemed clearer to use the actual words.

I pushed the change to the gui-release branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/dca6ecfd622c).

Rik <rik5>
Group administrator
Tue 18 Feb 2014 05:33:57 PM UTC, comment #4: 

With the patch, the original example works for me and all tests still pass.
I attached a mercurial changeset (with Sergei's name and mail retrieved from savanah profile) which is easier to import and test.



(file #30599)

Pantxo Diribarne <pantxo>
Group Member
Tue 18 Feb 2014 05:09:18 PM UTC, comment #3: 

i've attached a patch which could solve the problem. What do you think?

sergey plotnikov <nul0m>
Mon 17 Feb 2014 08:58:56 AM UTC, comment #2: 

Yep, I saw that comment and it was quite strange because I can't reproduce this "sloppy" behavior in Matlab.

You're right Octave works well in case '-not' is not the first argument, but it will also work incorrect if follows '-depth' or 'flat' argument:

octave:##> figure (1);
octave:##> li = plot (1:10,sin(1:10));
octave:##> ret = findobj (gcf,'flat','-not','type','axes')
ret = [](0x0)
octave:##> ret = findobj (gcf,'-depth',inf,'-not','type','axes')
ret = [](0x0)


sergey plotnikov <nul0m>
Sun 16 Feb 2014 11:51:01 AM UTC, comment #1: 

Here is what matlab returns for the provided example:


>> figure (1);
>> li = plot (1:10,sin(1:10));
>> ret = findobj (gcf,'-not','type','axes');
>> ret' == [gcf() li]
ans =

     1     1


I think this particular octave behavior was intended (see the comment in findobj.m near line 180) and it would be useful to have Ben's input here.

Octave works well as long as "-not" is not the first argument after the graphics handle:


>> figure (1);
>> li = plot (1:10,sin(1:10));
>> ret = findobj (gcf,'visible', 'on', '-not','type','axes');
>> ret' == [gcf() li]
ans =

     1     1


Pantxo Diribarne <pantxo>
Group Member
Fri 14 Feb 2014 03:50:25 PM UTC, original submission:  

Please try the following code to check if it can work well


figure;
plot(1:10,sin(1:10));
findobj(gcf,'-not','type','axes')


I would expect it to find handles of figure and line, but it finds nothing.

sergey plotnikov <nul0m>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30599:  bug41588.patch added by pantxo (1KiB - text/x-patch)
file #30597:  findobj_patch added by nul0m (1KiB - application/octet-stream - do you think this patch is enough to solve the problem? in my case it worked quite well.)

 

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 mtmiller (Updated the item)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by nul0m (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-21 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-02-18 pantxo Attached File- Added bug41588.patch, #30599
    2014-02-18 mtmiller StatusNone Patch Submitted
    2014-02-18 nul0m Attached File- Added findobj_patch, #30597

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code