Skip to content

Commit 285bcf6

Browse files
committed
io: for rule input don't use virtual function if class changed
1 parent d6356b3 commit 285bcf6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

io/io/src/TStreamerInfo.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,13 @@ namespace {
288288
memType = TVirtualStreamerInfo::kAnyP;
289289
}
290290
} else {
291-
if (memClass->IsTObject()) {
292-
memType = TVirtualStreamerInfo::kObject;
293-
} else if (memClass->GetCollectionProxy()) {
291+
if (memClass->GetCollectionProxy()) {
294292
memType = TVirtualStreamerInfo::kSTL;
293+
} else if(memClass->IsTObject() && memClass == element->GetClassPointer()) {
294+
// If there is a change in the class type, we can't use the TObject::Streamer
295+
// virtual function: it would streame the data using the in-memory type rather
296+
// than the onfile type.
297+
memType = TVirtualStreamerInfo::kObject;
295298
} else {
296299
memType = TVirtualStreamerInfo::kAny;
297300
}
@@ -349,6 +352,13 @@ namespace {
349352
void UpdateFromRule(const TStreamerInfo *info, const ROOT::TSchemaRule::TSources *s, TStreamerElement *element)
350353
{
351354
auto [memClass, memType, datasize, dimensions, totaldim] = GetSourceType(s, element);
355+
if (element->GetType() == TVirtualStreamerInfo::kObject && memClass != element->GetClassPointer())
356+
{
357+
// If there is a change in the class type, we can't use the TObject::Streamer
358+
// virtual function: it would streame the data using the in-memory type rather
359+
// than the onfile type.
360+
element->SetType(TVirtualStreamerInfo::kAny);
361+
}
352362
element->SetNewType( memType );
353363
element->SetNewClass( memClass );
354364
// We can not change the recorded dimensions. Let's check that

0 commit comments

Comments
 (0)