Skip to content

Commit

Permalink
output: fix segfault after file opening failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Aug 10, 2024
1 parent 4d36f45 commit 28e2f03
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/RMGRunAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,18 @@ void RMGRunAction::BeginOfRunAction(const G4Run*) {
// TODO: realpath
if (this->IsMaster())
RMGLog::Out(RMGLog::summary, "Opening output file: ", manager->GetOutputFileName());
ana_man->OpenFile(manager->GetOutputFileName());
} else if (this->IsMaster()) {
auto success = ana_man->OpenFile(manager->GetOutputFileName());

// If opening failed, disable persistency.
if (!success) {
if (this->IsMaster())
RMGLog::Out(RMGLog::error, "Failed opening output file ", manager->GetOutputFileName());
manager->EnablePersistency(false);
fIsPersistencyEnabled = false;
}
}

if (!fIsPersistencyEnabled && this->IsMaster()) {
// Warn user if persistency is disabled if there are detectors defined.
auto level = manager->GetDetectorConstruction()->GetActiveDetectorList().empty()
? RMGLog::summary
Expand Down

0 comments on commit 28e2f03

Please sign in to comment.