bugGNU Octave - Bugs: bug #57212, Figure import should map field...

 
 

bug #57212: Figure import should map field name "ApplicationData" to "__appdata__" for Matlab compatibility.

Submitted by:  None
Submitted on:  Tue 12 Nov 2019 08:20:50 AM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  dev
Operating System:  GNU/Linux

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)

Wed 27 Nov 2019 07:53:18 AM UTC, comment #18: 

Thanks for testing.
Closing as fixed.

Markus Mützel <mmuetzel>
Project Member
Tue 26 Nov 2019 11:13:28 PM UTC, comment #17: 

I can now load the file "TestFig.fig" that was attached to this bug report.  Is that enough confirmation that the patch is good?

Rik <rik5>
Project Administrator
Tue 26 Nov 2019 07:38:57 PM UTC, comment #16: 

I pushed this change that essentially moves the translation of the field names from hgload to struct2hdl:
http://hg.savannah.gnu.org/hgweb/octave/rev/d51b3c6f3892

Wanted to post this two days ago. But savannah was down.

Markus Mützel <mmuetzel>
Project Member
Mon 18 Nov 2019 12:09:23 PM UTC, comment #15: 

The translation of the field names should have been done recursively for all children.
I'll try to come up with something better in the next few days unless someone else will be faster.

Markus Mützel <mmuetzel>
Project Member
Sat 16 Nov 2019 05:29:32 PM UTC, comment #14: 

I pushed a patch here that maps "ApplicationData" to "__appdata__" when loading Matlab .fig files:
http://hg.savannah.gnu.org/hgweb/octave/rev/d30fcff9bad3

Marking as ready for test.

I also concur with Guillaume that the remaining issue is a duplicate of bug #44282.

Markus Mützel <mmuetzel>
Project Member
Wed 13 Nov 2019 04:59:45 PM UTC, comment #13: 

I just checked in Pantxo's patch for bug #57211.

Octave has its own internals for producing graphics that differ from Matlab.  I think it makes the most sense to translate between naming schemes at the periphery, i.e., during load/save.

Rik <rik5>
Project Administrator
Wed 13 Nov 2019 08:21:41 AM UTC, comment #12: 

Pantxo says in bug #57211, that renaming "__appdata__" to  "ApplicationData" should cause no trouble with backward compatibility.

@Markus: Do you have any objections?

Kai Torben Ohlhus <siko1056>
Project Member
Wed 13 Nov 2019 02:21:42 AM UTC, comment #11: 

> I'm not sure we can save .fig files in Octave that can be opened in Matlab. Please, correct me if I'm wrong.


No correction is necessary.  At work, I just tried again without success.  When using

>> h = openfig ("TestGUI.fig");
>> savefig (h, "TestGUI_octave.fig");

the latter one cannot be opened with MATLAB R2019a.  Same holds for hgsave-hgload with the options "-binary", "-text", "-v7", and "-v6".

You are right, Markus.  Doing the mapping in the import functions seems smarter to me too.  The error in getappdata is just a result of an incompatible naming convention.  The interface between Matlab and Octave are the import functions in this case.

Pantxo also touched this struct field recently in bug #57211 basically to hide it.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 12 Nov 2019 12:57:45 PM UTC, comment #10: 

I'm not sure we can save .fig files in Octave that can be opened in Matlab. Please, correct me if I'm wrong.

I'm slightly leaning towards mapping the content of "applicationdata" to "__appdata__" when loading a .fig file. Maybe in "hgload.m" or "struct2hdl.m".

Markus Mützel <mmuetzel>
Project Member
Tue 12 Nov 2019 12:23:22 PM UTC, comment #9: 

Agree to both of you Guillaume comment #6 and Markus comment #8.  Octave is far from full GUIDE support and I don't want to address bug #44282 here.  Neither we should aim to support Matlab/Octave "mishmash".  Matlab compatibility is a moving target of Octave, which should not come at any price.

While figuring out the problem of this item, the very small Matlab detail of comment #5 became apparent and I see two ways to handle the difference between fiendname "ApplicationData" (Matlab) and "__appdata__" (Octave):

1. Won't fix.  Octave decided for another name.
2. Let getappdata look for both fields.  Mishmash, when saving this figure and opening in Matlab again.
3. Break downwards compatibility with older Octave versions and rename that field according to Matlab.

I was fine with 1. or 2.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 12 Nov 2019 11:40:29 AM UTC, comment #8: 

@OP: You shouldn't use function files provided by Matlab in GNU Octave. I wouldn't consider errors caused by this mishmash "Matlab compatibility" errors, and they are out of the reach of what Octave can do.
Also, I'm pretty sure your violating their license if you do so.

Markus Mützel <mmuetzel>
Project Member
Tue 12 Nov 2019 09:50:52 AM UTC, comment #7: 

I edited the getappdata function just as you suggested and indeed this particular error disappears. Thank you!

Anonymous
Tue 12 Nov 2019 09:49:42 AM UTC, comment #6: 

This report should be renamed - the only issue here seems to be the absence of gui_mainfcn.m in Octave, i.e. a duplicate of bug #44282.

Guillaume <gyom>
Tue 12 Nov 2019 09:44:11 AM UTC, comment #5: 

I see.  Indeed the example TestGUI.m is not useful.  It boils down to the lack of knowledge, how does Matlab store appdata within a figure?  To my knowledge this is not officially documented.

But looking at your example TestGUI.fig, which is basically a mat-file only, it seems to be an easy fix:

Where Matlab uses the figure struct field "ApplicationData", Octave currently uses "__appdata__" instead.

A possible fix was to search for both fields to restore the appdata in a Matlab compatible way.

Can you try the following experiment:

edit getappdata

replace each "__appdata__" by "ApplicationData", save and run your example code again.

Does this at least resolve this particular error?  Then I can make up a more general solution for Octave itself.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 12 Nov 2019 09:07:03 AM UTC, comment #4: 

You're right, the example doesn't call getappdata. Sorry for the confusion but the error occurs in the function gui_mainfcn in Line 42, which is a Matlab-specific function. Then in gui_mainfcn, getappdata() is called, and that's where it crashes.
... I realise the example might not have been as helpful, since you also need Matlab on your machine to recreate the error. But you also can't reproduce the error by assigning whatever to a random figure in Octave, since the whole structure is GUI-specific.

Anonymous
Tue 12 Nov 2019 08:54:19 AM UTC, comment #3: 

Thank you for the example.  But I am afraid, that your given example does not contain a call to "getappdata" at all, or do I miss something?

Kai Torben Ohlhus <siko1056>
Project Member
Tue 12 Nov 2019 08:40:30 AM UTC, comment #2: 

Of course, I attached a test GUI.

(file #47839, file #47840)

Anonymous
Tue 12 Nov 2019 08:29:40 AM UTC, comment #1: 

Thank you for your bug report.  Can you attach some minimal meaningful example to reproduce the error?  That would be helpful.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 12 Nov 2019 08:20:50 AM UTC, original submission:  

I've built a GUI in Matlab (R2010a) and am now trying to open it using Octave on the same machine. When I try to execute it, I'm getting the following error

stopped in gui_mainfcn at line 175 [.../MATLAB/GUI/gui/gui_mainfcn.m]
175:     gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
error: structure has no member 'syscolorfig'
error: called from
    gui_mainfcn at line 181 column 9

Debugging revealed that the field 'GUIDEOptions' is stored in gui_hFigure.applicationdata, but the function getappdata() is looking for something like _appdata_. Matlab of course returns the correct output, even though I can't see the field _appdata_ nor applicationdata (I'm assuming that Matlab simply hides it).

Disclaimer: I'm aware that full GUIDE-compatibility is not given in Octave at the moment and that there are workarounds avoiding gui_mainfcn entirely, but I thought I'd report the incompatibility regarding getappdata() nonethless.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #47839:  TestGUI.fig added by None (5KiB - application/x-xfig)
file #47840:  TestGUI.m added by None (3KiB - text/x-objcsrc)

 

Digest:
   bug dependencies.

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 mmuetzel (Posted a comment)
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by None (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-11-27 mmuetzel StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-11-16 mmuetzel StatusNeed Info => Ready For Test
        Dependencies- => Depends on bugs #44282
    2019-11-13 siko1056 Dependencies- => Depends on bugs #57211
    2019-11-13 siko1056 Summarygetappdata should search for the struct fieldname "ApplicationData" within figure objects for Matlab compatibility => Figure import should map field name "ApplicationData" to "__appdata__" for Matlab compatibility.
    2019-11-12 siko1056 SummaryMatlab incompatibility in getappdata() when opening GUIDE-built .fig files => getappdata should search for the struct fieldname "ApplicationData" within figure objects for Matlab compatibility
    2019-11-12 siko1056 StatusNone => Need Info
    2019-11-12 None Attached File- => Added TestGUI.fig, #47839
        Attached File- => Added TestGUI.m, #47840
    2019-11-12 siko1056 Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 3 - Low

    Back to the top


    Powered by Savane 3.5