Skip to content

Commit 5ece687

Browse files
authored
Fix use of deleted assignment operator for gDirectory under ROOT 6.24 in StFwdTrackMaker (#757)
Replaced `gDirectory = prevDir` with `prevDir->cd()` to avoid compilation error with ROOT 6.24 ``` .sl73_x8664_gcc485/OBJ/StRoot/StFwdTrackMaker/StFwdQAMaker.cxx: In member function 'virtual int StFwdQAMaker::Finish()': .sl73_x8664_gcc485/OBJ/StRoot/StFwdTrackMaker/StFwdQAMaker.cxx:196:20: error: use of deleted function 'ROOT::Internal::TDirectoryAtomicAdapter& ROOT::Internal::TDirectoryAtomicAdapter::operator=(const ROOT::Internal::TDirectoryAtomicAdapter&)' gDirectory = prevDir; ^ In file included from /cvmfs/star.sdcc.bnl.gov/star-spack/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/root-6.24.06-ojgeqx4c6cazamrg2mltgfm3wpivwzyf/include/TDirectoryFile.h:25:0, from /cvmfs/star.sdcc.bnl.gov/star-spack/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/root-6.24.06-ojgeqx4c6cazamrg2mltgfm3wpivwzyf/include/TFile.h:28, from StRoot/StChain/StMaker.h:20, from StRoot/StFwdTrackMaker/StFwdQAMaker.h:11, from .sl73_x8664_gcc485/OBJ/StRoot/StFwdTrackMaker/StFwdQAMaker.cxx:1: /cvmfs/star.sdcc.bnl.gov/star-spack/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/root-6.24.06-ojgeqx4c6cazamrg2mltgfm3wpivwzyf/include/TDirectory.h:247:11: note: 'ROOT::Internal::TDirectoryAtomicAdapter& ROOT::Internal::TDirectoryAtomicAdapter::operator=(const ROOT::Internal::TDirectoryAtomicAdapter&)' is implicitly deleted because the default definition would be ill-formed: struct TDirectoryAtomicAdapter { ^ /cvmfs/star.sdcc.bnl.gov/star-spack/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/root-6.24.06-ojgeqx4c6cazamrg2mltgfm3wpivwzyf/include/TDirectory.h:247:11: error: non-static reference member 'std::atomic<TDirectory*>& ROOT::Internal::TDirectoryAtomicAdapter::fValue', can't use default assignment operator cons: *** [.sl73_x8664_gcc485/OBJ/StRoot/StFwdTrackMaker/StFwdQAMaker.o] Error 1 cons: errors constructing .sl73_x8664_gcc485/OBJ/StRoot/StFwdTrackMaker/StFwdQAMaker.o ```
1 parent b26866e commit 5ece687

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

StRoot/StFwdTrackMaker/StFwdQAMaker.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,18 @@ int StFwdQAMaker::Finish() {
182182

183183
//beginning new
184184
if ( mLocalOutputFile != "" ){
185-
auto prevDir = gDirectory;
185+
TDirectory* prevDir = TDirectory::CurrentDirectory();
186186

187187
// output file name
188188
TFile *fOutput = new TFile(mLocalOutputFile, "RECREATE");
189189
fOutput->cd();
190190
for (auto nh : mHists) {
191-
nh.second->SetDirectory(gDirectory);
191+
nh.second->SetDirectory(TDirectory::CurrentDirectory());
192192
nh.second->Write();
193193
}
194194

195195
// restore previous directory
196-
gDirectory = prevDir;
196+
prevDir->cd();
197197

198198
LOG_INFO << "Done writing StFwdQAMaker output to local file : " << mLocalOutputFile << endm;
199199
}//end new

StRoot/StFwdUtils/StFwdAnalysisMaker.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ StFwdAnalysisMaker::StFwdAnalysisMaker() : StMaker("fwdAna"){
2828
int StFwdAnalysisMaker::Finish() {
2929

3030
if ( mLocalOutputFile != "" ){
31-
auto prevDir = gDirectory;
31+
TDirectory* prevDir = TDirectory::CurrentDirectory();
3232

3333
// output file name
3434
TFile *fOutput = new TFile(mLocalOutputFile, "RECREATE");
3535
fOutput->cd();
3636
for (auto nh : mHists) {
37-
nh.second->SetDirectory(gDirectory);
37+
nh.second->SetDirectory(TDirectory::CurrentDirectory());
3838
nh.second->Write();
3939
}
4040

4141
// restore previous directory
42-
gDirectory = prevDir;
42+
prevDir->cd();
4343

4444
LOG_INFO << "Done writing StFwdAnalysisMaker output to local file : " << mLocalOutputFile << endm;
4545
}

0 commit comments

Comments
 (0)