# HG changeset patch # User Rik # Date 1394744315 25200 # Node ID 5ec4b7006b82f10a7776bcc5dfdb4bdbc18045c6 # Parent b83fca22bb4cd4dc052bac915069eed3327800d8 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. diff -r b83fca22bb4c -r 5ec4b7006b82 scripts/plot/util/copyobj.m --- 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