LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Error while duplicating a panel with control dynamically associated to a splitter

When you try to duplicate a panel where a control has been dynamically created and associated to a splitter, you receive error -153: Item is already attached to splitter control.

See attached project which shows this behaviour: you can move the splitter and have controls moved accordingly; you can also duplicate the panel whith the splitter fully operative. If you press "Duplicate Numeric" button, existing numeric is duplicated and the new control is attached to the splitter. After this, trying to duplicate the panel generates error -153. If you duplicate the control but do not add it to the splitter no error is received while duplicating the panel.

 

Tested in CVI2009SP1. There is no evidence of this error in Known Issues document for later versions.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 1 of 5
(2,796 Views)

Going a little bit further on this subject, if Ifirst call RemoveCtrlFromSplitter and then duplicating the panel, I receive no error even if the panel has other controls attached to the splitter (provided they have been attache in the UIR editor, not programmatically).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(2,767 Views)

Hi Roberto,

 

Thanks for the nicely stripped down test program! Easy to reproduce bugs are a rare pleasure...

 

I did confirm the bug, which has been there since CVI 7.1. It is triggered by the presence, at the time that the panel is copied, of a splitter-attached control, which was itself duplicated from another control that had been loaded from a UIR (whether or not the original control is also attached to the splitter). Whew. That was long.

 

In simpler terms, it's not the fact that the control was dynamically attached to the splitter that is causing the problem. It's the fact that the control was duplicated from another control.

 

The problem happens because a duplicated control inherits the constant name of the original control. Normally, this is not a problem for runtime-only controls. However, the splitter was still assuming that constant names of its attached controls were all unique, and that's what caused the problem.

 

Bug id: 392640

 

Unfortunately, there isn't a great workaround, since you can't prevent the duplicated control from inheriting the constant name, nor can you change its constant name after the fact. I can think of two possibilities:

 

  1. Don't duplicate the control. Create it using NewCtrl instead, and then apply the necessary configurations.
  2. Temporarily detach the duplicate control from the splitter prior to copying the panel, then attach it back (in both the original panel and the duplicated panel) after the panel copy.

Luis

0 Kudos
Message 3 of 5
(2,764 Views)

Just noticed your update now, after posting my reply. Looks like you've already hit on workaround #2.

 

Sorry, it took me a while to look into this.

 

Luis

0 Kudos
Message 4 of 5
(2,763 Views)

Thanks Luis for looking into this. Yes, I got into a workaround that is working for me so I'm ok on this.

 


LuisG ha scritto:

 

Easy to reproduce bugs are a rare pleasure...


Seems we are in the same world: every now and then I need to work on some customers bug notice but very often I cannot reproduce the exact situation! Just yesterday a person told me "can't you step through the whole program to try finding the error?" Smiley Frustrated



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(2,737 Views)