changeset 28311:f9b5357f4a7e

struct2hdl.m: Allowing loading old figure files (bug #58336). * struct2hdl.m: Fall back to using "activepositionproperty" when loading an figure file that was saved before the axes property "positionconstraint" existed.
author Markus Mützel <markus.muetzel@gmx.de>
date Mon, 18 May 2020 14:44:10 +0200
parents 1379ebcb00c3
children dddc6c2661bc
files scripts/plot/util/struct2hdl.m
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/struct2hdl.m	Mon May 18 13:02:20 2020 +0200
+++ b/scripts/plot/util/struct2hdl.m	Mon May 18 14:44:10 2020 +0200
@@ -112,12 +112,18 @@
   names = [names(! n); names(n)];
   n_pos = find (strcmp (names, "position") | strcmp (names, "outerposition"));
   if (strcmp (s.type, "axes") && numel (n_pos) == 2)
-    if (strcmp (s.properties.positionconstraint, "innerposition"))
+    if (isfield (s.properties, "positionconstraint"))
+      positionconstraint = s.properties.positionconstraint;
+    else
+      ## loading old figure file before "positionconstraint" property was added
+      positionconstraint = s.properties.activepositionproperty;
+    endif
+    if (strcmp (positionconstraint, "outerposition"))
+      names{n_pos(1)} = "position";
+      names{n_pos(2)} = "outerposition";
+    else
       names{n_pos(1)} = "outerposition";
       names{n_pos(2)} = "position";
-    else
-      names{n_pos(1)} = "position";
-      names{n_pos(2)} = "outerposition";
     endif
   endif
   ## Reorder the properties with the mode properties coming last