From 939fdebbb451240ae8988694b381f24f048d60cc Mon Sep 17 00:00:00 2001 From: Enrico Guiraud Date: Wed, 22 Mar 2017 17:51:16 +0100 Subject: [PATCH] [TDF] Allow proper re-usage of TDataFrameValues Before this fix TDataFrame could attempt to re-use invalidated TTreeReader{Value,Array}s in certain conditions. --- tree/treeplayer/inc/ROOT/TDFNodes.hxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tree/treeplayer/inc/ROOT/TDFNodes.hxx b/tree/treeplayer/inc/ROOT/TDFNodes.hxx index 6f33f8f8e4de5..d23ae7b9f85e6 100644 --- a/tree/treeplayer/inc/ROOT/TDFNodes.hxx +++ b/tree/treeplayer/inc/ROOT/TDFNodes.hxx @@ -137,6 +137,7 @@ public: void MakeProxy(TTreeReader &r, const std::string &bn) { + Reset(); bool useReaderValue = std::is_same::value; if (useReaderValue) fReaderValue.reset(new TTreeReaderValue(r, bn.c_str())); @@ -163,6 +164,14 @@ public: return std::array_view(fReaderArray->begin(), fReaderArray->end()); } + + void Reset() { + fReaderValue = nullptr; + fReaderArray = nullptr; + fValuePtr = nullptr; + fTmpColumn = nullptr; + fSlot = 0; + } }; template @@ -528,6 +537,7 @@ public: template void ROOT::Internal::TDataFrameValue::SetTmpColumn(unsigned int slot, ROOT::Detail::TDataFrameBranchBase *tmpColumn) { + Reset(); fTmpColumn = tmpColumn; if (tmpColumn->GetTypeId() != typeid(T)) throw std::runtime_error(std::string("TDataFrameValue: type specified is ") + typeid(T).name() +