Broken TDirectoryFile::FindObjectAny and TDirectoryFile::FindKeyAny

Hi Pepe,

TDirectoryFile::GetKey and FindKey also (somewhat surprisingly) behaves like *Any. However you can still do what you want with:

TKey *key = file->GetKey(name,cycle); // Or FindKey(namewithcycle);
if (key->GetCycle() == cycle) {
    return key;
} else { 
    return nullptr;
}

[quote]I remember that if I try to retrieve objects with “GetObject”, then always only the very recently retrieved “cycle” stays in memory (any previously retrieved “cycle” is automatically deleted from memory).[/quote]Indeed GetObject keeps only one cycle in memory … if and only if it manages the object lifetime (so this affect only TTree and TH* (and a few more) and the only explicitly delegated by the user).

So to keep multiple cycle in memory and use GetObject you can do:

TObject *v1 = nullptr;
TObject *v2 = nullptr;
directory->GetObject(namecycle1, v1);
if (v1) directory->Remove(v1);
directory->GetObject(namecycle2, v2);
if (v2) directory->Remove(v2);

Cheers,
Philippe.