From f5bd84dd335f1ddd4d3caa70e12c27d18103ac70 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 11 Mar 2024 10:53:53 +0100 Subject: [PATCH 1/2] [core] proper check whether class is a TRef or TRefArray Fixes https://its.cern.ch/jira/projects/ROOT/issues/ROOT-7052 --- core/meta/src/TStreamerElement.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/meta/src/TStreamerElement.cxx b/core/meta/src/TStreamerElement.cxx index f2875f1a3cb61..7c637153825dd 100644 --- a/core/meta/src/TStreamerElement.cxx +++ b/core/meta/src/TStreamerElement.cxx @@ -30,6 +30,7 @@ #include "ThreadLocalStorage.h" #include "TList.h" #include "TRef.h" +#include "TRefArray.h" #include "TInterpreter.h" #include "TError.h" #include "TObjArray.h" @@ -287,7 +288,7 @@ Bool_t TStreamerElement::CannotSplit() const } //////////////////////////////////////////////////////////////////////////////// -/// Returns a pointer to the TClass of this element. +/// Returns a pointer to the TClass of this element and updates fClassObject. TClass *TStreamerElement::GetClassPointer() const { @@ -306,8 +307,9 @@ TClass *TStreamerElement::GetClassPointer() const Int_t TStreamerElement::GetExecID() const { //check if element is a TRef or TRefArray - if (strncmp(fTypeName.Data(),"TRef",4) != 0) return 0; - + const TString clName = ExtractClassName(fTypeName); + if (clName != "TRef" && clName != "TRefArray") return 0; + //if the UniqueID of this element has already been set, we assume //that it contains the exec id of a TRef object. if (GetUniqueID()) return GetUniqueID(); From 293f2dee03d8e2daacd3b5e1e0d375573f2b1eba Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 12 Mar 2024 17:18:33 +0100 Subject: [PATCH 2/2] [core] allow also EXEC in classes derived from TRef/TRefArray, if preloaded --- core/meta/src/TStreamerElement.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/meta/src/TStreamerElement.cxx b/core/meta/src/TStreamerElement.cxx index 7c637153825dd..adc3640a90d21 100644 --- a/core/meta/src/TStreamerElement.cxx +++ b/core/meta/src/TStreamerElement.cxx @@ -306,9 +306,10 @@ TClass *TStreamerElement::GetClassPointer() const Int_t TStreamerElement::GetExecID() const { - //check if element is a TRef or TRefArray + //check if element is a TRef or TRefArray; or if it inherits from them and class was preloaded const TString clName = ExtractClassName(fTypeName); - if (clName != "TRef" && clName != "TRefArray") return 0; + TClass* const type = TClass::GetClass(clName, kFALSE, kTRUE); // do NOT update fClassObject via GetClassPointer ! and do NOT call GetClass with load=true, otherwise you'll get several failing roottests. Do NOT call TRef::Class() or TRefArray::Class() either + if (clName != "TRef" && clName != "TRefArray" && (!type || !(type->InheritsFrom(TClass::GetClass("TRef", kFALSE, kTRUE)) || type->InheritsFrom(TClass::GetClass("TRefArray", kFALSE, kTRUE))))) return 0; //if the UniqueID of this element has already been set, we assume //that it contains the exec id of a TRef object.