Mon 13 Jun 2016 09:59:50 AM UTC, comment #11:
In Matlab, the order of the creation of the two uipanels does not matter and I don't seen any difference between using "allchild(F)" and "allchild(gcbf)".
|
Fri 10 Jun 2016 05:26:14 PM UTC, comment #10:
And what if the order of creation is reversed in old Matlab as well?
Does "allchild(F)" in the callback give the same list as "allchild(gcbf)"? Just want to make sure it's not some special view of the figure object that has different properties for the duration of the callback.
Assuming those are both fine, and the order we are doing things is backwards, the change looks like reversing the order of gh_manager::free(h) and parent.remove_child(h) in a few places in graphics.cc. Some other devs more familiar with the graphics system should weigh in on whether this is safe or worth doing.
|
Fri 10 Jun 2016 04:31:31 PM UTC, comment #9:
Here is what an 'old' version of Matlab returns:
(the extra handles correspond to the toolbar and menus)
|
Fri 10 Jun 2016 04:26:50 PM UTC, comment #8:
Thanks. I notice two things: the first one is that the error depends on the order in which the two uipanels are created. The following returns an error with Octave:
while this runs fine:
Matlab behaviour follows in the next comment.
|
Fri 10 Jun 2016 04:25:08 PM UTC, comment #7:
By the way, there is a comment in the Octave sources dating from 2011 claiming an intentional order of operations here:
> NOTE: free the handle before removing it from its parent's
> children, such that the object's state is correct when the
> deletefcn callback is executed
This seems to imply that the decision was made intentionally to delete the child object, which calls its deletefcn callback function, before removing it from the parent's "children" list. So which way is correct?
|
Fri 10 Jun 2016 04:10:05 PM UTC, comment #6:
Ok, reopening and retitling to reflect that specific error.
Can you show what the contents of allchild(F) is before and during the callback? Maybe Matlab is removing the uipanel from the children list before calling the deletefcn callback?
|
Fri 10 Jun 2016 04:02:39 PM UTC, comment #5:
Thanks, Mike. Sorry, this bug report is confusing because I mentioned two separate issues and the title I chose relate to the second issue that is of lesser importance.
I agree that deleting a deleted handle is not a primary problem and can be left for later when/if graphics handles are implemented as objects.
There is still the issue that the following code returns an error:
while it runs OK even for Matlab versions that implement graphics handles as double.
|
Fri 10 Jun 2016 03:41:12 PM UTC, comment #4:
I see.
So we are behaving correctly within the constraints of what we have support for currently in Octave.
I don't think there is much point to keeping this open just to remember this for when graphics handle objects are actually implemented.
|
Fri 10 Jun 2016 09:25:29 AM UTC, comment #3:
Mike,
your examples throw the error "Invalid or deleted object."
This error is also thrown for the following example in current Matlab versions:
The reason why no error is thrown for the original example in comment #0 is probably that recent versions of Matlab return a graphics object instead of a double for handles.
See: http://de.mathworks.com/help/matlab/graphics_transition/graphics-handles-are-now-objects-not-doubles.html
Octave did not (yet?) make this transition.
|
Fri 10 Jun 2016 09:20:26 AM UTC, comment #2:
You get this:
In recent Matlab versions, handles are objects:
allowing for a second silent deletion as in original post. With older Matlab versions, relying on doubles to store handles, you get:
i.e. the same error message that you get with delete(42).
I might have added confusion to this thread though as the initial problem is somehow different as older Matlab versions (that behave like Octave regarding deletion of an already deleted handle) do not crash when the figure containing the uipanels is closed.
It seems that the code in graphics.cc (_go_delete_ and delete_graphics_objects) takes care of handles that might have been already deleted by a callback function but it must miss a case.
|
Thu 09 Jun 2016 04:42:11 PM UTC, comment #1:
What about this in Matlab (in a fresh session with no handles)?
No errors or warnings, just silently do nothing?
|
Thu 09 Jun 2016 04:23:51 PM UTC, original submission:
Here is a simplified version of a situation I came across:
Closing the figure removes the right panel then crashes with this error message:
In particular, with Octave:
whereas in Matlab:
|