octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange handle behavior (was Re: [Changeset]: Re: cla() ?)


From: Michael Goffioul
Subject: Re: Strange handle behavior (was Re: [Changeset]: Re: cla() ?)
Date: Wed, 8 Oct 2008 16:55:42 +0200

On Wed, Oct 8, 2008 at 3:25 PM, Ben Abbott <address@hidden> wrote:
> Nice deduction.
>
> If I place a "drawnow" after "plot(1:10)" then the script does produce the
> "invalid handle" error :-)
>
> Does this indicate that "get(hc,...)" command is effectively executed prior
> to the "delete(hc)"?

No. If you look carefully at the result of the get(hc) when you type
it manually,
then you see that it's a text object, most probably one of the labels or title
of the current axes object. This is a side-effect of the handle recycling that
we already talked about in a previous thread, in combination with the fact that
the title and labels text object are created on-demand (for instance during a
drawnow execution).

I think what's happening is the following:
when you run the script
- the "plot" call creates the axes and the line object
- initially the title and labels object are no created
- as you are in a m-script, no drawnow occurs
- during the "delete" call, the line object is deleted and the
  handle is recycled
- the final "get" call fails, because hc is an invalid handle
when you return to the prompt
- drawnow is executed
- title and labels objects are created by the execution of
  drawnow (because drawnow accesses Title and XYZLabel
  properties)
- the first object created will recycle the hc value
- get(hc) does not fails, because it is now a valid (text) object

That's why I think handle recycling is not a good idea...

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]