Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions fairroot/base/sink/FairSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
#define FAIRSINK_H

#include <Rtypes.h>
#include <TFolder.h>
#include <TObject.h>
#include <TString.h>
#include <TTree.h>
#include <map> // map
#include <memory> // unique_ptr
#include <string> // string
#include <typeinfo> // type_info

class TObject;
class TFolder;
class TTree;

enum Sink_Type
{
kONLINESINK,
Expand All @@ -40,6 +39,12 @@ class FairSink
virtual ~FairSink();

virtual Bool_t InitSink() = 0;

/**
* \note It might be called multiple times, please handle that.
* \note It will be called from the dtor of FairRun.
* Don't interact with FairRun here.
*/
virtual void Close() = 0;
virtual void Reset() = 0;

Expand Down
6 changes: 6 additions & 0 deletions fairroot/base/source/FairSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class FairSource : public TObject
virtual Bool_t Init() = 0;
virtual Int_t ReadEvent(UInt_t = 0) = 0;
virtual Bool_t SpecifyRunId() = 0;

/**
* \note It might be called multiple times, please handle that.
* \note It will be called from the dtor of FairRun.
* Don't interact with FairRun here.
*/
virtual void Close() = 0;
virtual void Reset() = 0;
virtual Bool_t ActivateObject(TObject**, const char*) { return kFALSE; }
Expand Down
7 changes: 7 additions & 0 deletions fairroot/base/steer/FairRun.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ FairRun::~FairRun()
{
LOG(debug) << "Enter Destructor of FairRun";

if (fSource) {
fSource->Close();
}
if (fSink) {
fSink->Close();
}
Comment on lines +85 to +90

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we should just let program crash if fSource or fSink somehow is nullptr.

Suggested change
if (fSource) {
fSource->Close();
}
if (fSink) {
fSink->Close();
}
fSource->Close();
fSink->Close();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, FairRunSim does not have a Source. So it doesn't need to close it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah, that makes sense.


// So that FairRootManager does not try to delete these, because we will do that:
fRootManager->SetSource(nullptr);
fRootManager->SetSink(nullptr);
Expand Down