Fixed (1.20.1.6) GetAtomUIDs weirdness

MacGruber

Invaluable member
Developer
Wiki Contributor
Featured Contributor
Messages
1,607
Reactions
3,169
Points
143
I stumbled across an issue with SuperController.GetAtomUIDs(). The implementation currently looks like this:
C#:
public List<string> GetAtomUIDs()
{
    if (showHiddenAtoms)
    {
        return sortedAtomUIDs;
    }
    if (sortAtomUIDs)
    {
        return visibleAtomUIDs;
    }
    return atomUIDs;
}
Since sortAtomUIDs seems to be always true, you might only get the visible atoms. However, this is called in cases where you would want ALL atoms. For example SuperController.RenameAtom() is calling this, which can result in sending the OLD list of atoms out to anyone listening to OnAtomUIDsChanged, because visibleAtomUIDs was not yet updated at that point.

Currently, in my plugin I came up with a workaround:
C#:
private List<string> GetAllAtomUIDs()
{
    // working around VaM weirdness not returning hidden atoms
    SuperController sc = SuperController.singleton;
    bool wasSorted = sc.sortAtomUIDs;
    sc.sortAtomUIDs = false;
    List<string> atomUIDs = sc.GetAtomUIDs();
    sc.sortAtomUIDs = wasSorted;           
    return atomUIDs;
}

However, to allow us coders to keep our sanity, my suggestion would be to have GetAtomUIDs() just always return ALL atoms, either sortedAtomUIDs or atomUIDs. And then have a second method GetVisibleAtomUIDs() to make clear what you get.

@Acid Bubbles I think this is what is causing the issue with atom cloning in your Keybindings plugin :)
 
Yeah you are right - in general this function should return all atom uids sorted. I need to make another function for the few places I actually use this and need it to return only visible atom uids. And you are right there are several internal bugs caused by this internally.
 
@meshedvr Great! Can give a vague ETA for the release containing this fix? Days, weeks or months?
I want to release a new version of Life today or tomorrow and need to know whether or not to use above workaround. Can I assume the workaround will keep working with the new version?
 
Oh and yes your workaround will still work.

This is the new code for the function:

Code:
    public List<string> GetAtomUIDs() {
        if (sortAtomUIDs) {
            return sortedAtomUIDs;
        } else {
            return atomUIDs;
        }
    }
 
Back
Top Bottom