Skip to content

vcs.Gfb.rename() seems to destroy the object that it's renaming #2116

Description

Here's a session example that I'm running in ipython now:

>>> b = vcs.createboxfill()
>>> b
<vcs.boxfill.Gfb at 0x1021f5ec0>
>>> b.name
'__boxfill_419032409050676'
>>> b.rename("test")
>>> vcs.elements['boxfill']['test']
<vcs.boxfill.Gfb at 0x1021f5ec0>
>>> vcs.show('boxfill')
*******************Boxfill Names List**********************
a_boxfill            a_lambert_boxfill    a_mollweide_boxfill 
a_polar_boxfill      a_robinson_boxfill   default             
polar                quick                robinson            
test                
*******************End Boxfill Names List**********************
>>> new_b = vcs.getboxfill('test')
>>> new_b
<vcs.boxfill.Gfb at 0x1021f5ec0>
>>> new_b.name
'__boxfill_419032409050676'
# assume we have a cdms2 variable named 's', and a Canvas named 'a'
>>> a.boxfill(s,b)
vcsError: Error source boxfill object (__boxfill_419032409050676) does not exist!

As we can see from the example, this leaves behind a reference to the renamed boxfill in the names list while making that boxfill unusable, because it is deleted.

I think the issue is that we should just be creating a new boxfill here, instead of using vcs.elements to re-assign things:
gfb_rename

Not sure if this is a widespread problem (affecting more than just Gfb).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions