Current Position:Home > Error while duplicating a panel with control dynamically associated to a splitter

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

Update:10-11Source: network consolidation
Advertisement
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 Zone Community
If I have helped you, why not giving me a kudos?
Attachments:
DplPnl.zip ‏7 KB

The Best Answer

Advertisement
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:
Don't duplicate the control. Create it using NewCtrl instead, and then apply the necessary configurations.
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