Skip to content

Commit b6cb095

Browse files
committed
[core] Force the reference branch to load when accessing by index
fixes ROOT-3594
1 parent 5e58656 commit b6cb095

2 files changed

Lines changed: 28 additions & 29 deletions

File tree

core/cont/inc/TRefArray.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,4 @@ inline Bool_t TRefArray::BoundsOk(const char *where, Int_t at) const
161161
: kTRUE;
162162
}
163163

164-
inline TObject *TRefArray::operator[](Int_t at) const
165-
{
166-
int j = at-fLowerBound;
167-
if (j >= 0 && j < fSize) {
168-
if (!fPID) return nullptr;
169-
if (!TProcessID::IsValid(fPID)) return nullptr;
170-
TObject *obj = fPID->GetObjectWithID(fUIDs[j]);
171-
if (!obj) obj = GetFromTable(j);
172-
return obj;
173-
}
174-
BoundsOk("At", at);
175-
return nullptr;
176-
}
177-
178-
inline TObject *TRefArray::At(Int_t at) const
179-
{
180-
// Return the object at position i. Returns 0 if i is out of bounds.
181-
int j = at-fLowerBound;
182-
if (j >= 0 && j < fSize) {
183-
if (!fPID) return nullptr;
184-
if (!TProcessID::IsValid(fPID)) return nullptr;
185-
TObject *obj = fPID->GetObjectWithID(fUIDs[j]);
186-
if (!obj) obj = GetFromTable(j);
187-
return obj;
188-
}
189-
BoundsOk("At", at);
190-
return nullptr;
191-
}
192-
193164
#endif

core/cont/src/TRefArray.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,3 +966,31 @@ TObject *TRefArrayIter::operator*() const
966966
return (((fCurCursor >= 0) && (fCurCursor < fArray->Capacity())) ?
967967
fArray->At(fCurCursor) : nullptr);
968968
}
969+
970+
TObject *TRefArray::operator[](Int_t at) const
971+
{
972+
return At(at);
973+
}
974+
975+
TObject *TRefArray::At(Int_t at) const
976+
{
977+
// Return the object at position i. Returns 0 if i is out of bounds.
978+
int j = at - fLowerBound;
979+
if (j >= 0 && j < fSize) {
980+
981+
auto table = TRefTable::GetRefTable();
982+
table->Notify();
983+
984+
if (!fPID || !TProcessID::IsValid(fPID)) return nullptr;
985+
986+
auto obj = fPID->GetObjectWithID(fUIDs[j]);
987+
if (obj) return obj;
988+
989+
if ((obj = GetFromTable(j))) return obj;
990+
991+
return nullptr;
992+
993+
}
994+
BoundsOk("At", at);
995+
return nullptr;
996+
}

0 commit comments

Comments
 (0)