changeset 18570:5ec4b7006b82

copyobj.m: Fix bug when restoring axes to a figure that had no axes to begin with (bug #41849). * copyobj.m: Get axes using get (cf, "currentaxes") rather than gca to avoid creating axes when they do not exist. When restoring axes at the end of function, only do so if ca is not empty.
author Rik <rik@octave.org>
date Thu, 13 Mar 2014 13:58:35 -0700
parents b83fca22bb4c
children 3dac2a233386
files scripts/plot/util/copyobj.m
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/copyobj.m	Fri Mar 07 13:02:43 2014 -0500
+++ b/scripts/plot/util/copyobj.m	Thu Mar 13 13:58:35 2014 -0700
@@ -46,7 +46,7 @@
 
   ## current figure and axes
   cf = gcf ();
-  ca = gca ();
+  ca = get (cf, "currentaxes");
   
   ## compatibility of input handles
   kididx = find (strcmp (alltypes, get (horig).type));
@@ -65,7 +65,7 @@
 
   ## reset current figure (and eventually axes) to original
   set (0, "currentfigure", cf);
-  if (get (hnew, "parent") == cf)
+  if (get (hnew, "parent") == cf && ! isempty (ca))
     set (cf, "currentaxes", ca)
   endif