Skip to content

Commit

Permalink
avoid segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Dec 2, 2023
1 parent 5ca97ce commit dcc6ac8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/geant4_application/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ void Application::ListCommands(const string& directory) {
}

const PrimaryGeneratorAction& Application::GetPrimaryGeneratorAction() const {
// mostly to give Python easy access to the static methods
if (runManager == nullptr) {
throw runtime_error("RunManager needs to be set up first");
}
const auto primaryGeneratorAction = dynamic_cast<const PrimaryGeneratorAction*>(runManager->GetUserPrimaryGeneratorAction());
if (primaryGeneratorAction == nullptr) {
throw runtime_error("Primary generator action is not available");
Expand All @@ -170,7 +172,9 @@ const PrimaryGeneratorAction& Application::GetPrimaryGeneratorAction() const {
}

const StackingAction& Application::GetStackingAction() const {
// mostly to give Python easy access to the static methods
if (runManager == nullptr) {
throw runtime_error("RunManager needs to be set up first");
}
const auto stackingAction = dynamic_cast<const StackingAction*>(runManager->GetUserStackingAction());
if (stackingAction == nullptr) {
throw runtime_error("Stacking action is not available");
Expand All @@ -179,7 +183,9 @@ const StackingAction& Application::GetStackingAction() const {
}

const DetectorConstruction& Application::GetDetectorConstruction() const {
// mostly to give Python easy access to the static methods
if (runManager == nullptr) {
throw runtime_error("RunManager needs to be set up first");
}
const auto detectorConstruction = dynamic_cast<const DetectorConstruction*>(runManager->GetUserDetectorConstruction());
if (detectorConstruction == nullptr) {
throw runtime_error("Detector construction is not available");
Expand Down

0 comments on commit dcc6ac8

Please sign in to comment.