Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Deleting boxes and arrows (Read 3176 times)
MagnusSpeychal
Junior Member
**
Offline



Posts: 53
Joined: Jun 18th, 2007
Deleting boxes and arrows
Jul 17th, 2007 at 8:24am
Print Post  
Hi

When deleting a box, any arrows between this box and other boxes are also deleted. If the "ArrowDeleted" event is handled I have noticed that one can still obtain information (Tag, UserString etc.) from the box which was deleted.
My question is thus, When is it no longer possible to obtain information about a deleted box and what can be done to it besides obtaining info?


Best regards,
Magnus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Deleting boxes and arrows
Reply #1 - Jul 17th, 2007 at 10:02am
Print Post  
Hi,

The box object is deleted immediately after raising the arrow events, and its memory is freed. It is not safe to keep a reference to that object and use it in any way afterwards.

Stoyan
  
Back to top
 
IP Logged
 
MagnusSpeychal
Junior Member
**
Offline



Posts: 53
Joined: Jun 18th, 2007
Re: Deleting boxes and arrows
Reply #2 - Jul 17th, 2007 at 10:25am
Print Post  
Hi Stoyan

If I understand you correctly, using the commands:

arrow.GetOriginBox();
arrow.GetDestinationBox();

in the "ArrowDeleted" event is a very bad idea! Am I right?

How about when deleting a box. Is it safe to use the "box" item in the "BoxDeleted" event?


Best regards,
Magnus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Deleting boxes and arrows
Reply #3 - Jul 17th, 2007 at 11:37am
Print Post  
Hi Magnus,

You should still be able to access the box and read its properties from the Deleted events. However keeping a reference to the box and using it after exiting from the event handlers is not safe. Creating links or groups related to the box being deleted is not a good idea either.

Stoyan
  
Back to top
 
IP Logged
 
MagnusSpeychal
Junior Member
**
Offline



Posts: 53
Joined: Jun 18th, 2007
Re: Deleting boxes and arrows
Reply #4 - Jul 17th, 2007 at 11:56am
Print Post  
Hi Stoyan

Thank you!
So the commands:

arrows.GetOriginBox();
arrows.GetDestinationBox();

are OK as long as they are used within the "ArrowDeleted" event?

Also:
I have two boxes connected by an arrow. When one box is deleted the other one should be deleted as well. First I put some code in the "BoxDeleted" event to do this using the arrow connecting the boxes. This did not work since when deleting a box, the code in the "ArrowDeleted" started executing directly so that when the code in "BoxDeleted" should execute the arrow was  not available!
Second I tried putting some code in the "RequestDeleteBox" event but this did not work either. This code included a for-loop but this only executed once and control never returned to this loop.

Any ideas?

Best regards,
Magnus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Deleting boxes and arrows
Reply #5 - Jul 17th, 2007 at 12:58pm
Print Post  
Hi Magnus,

Yes, that should work fine.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint