From 24b97bf9d7501e169f39e15012b441e3ba3c5d59 Mon Sep 17 00:00:00 2001
From: Philipp Suffa <philipp.suffa@fau.de>
Date: Thu, 6 Feb 2025 16:00:27 +0100
Subject: [PATCH] Fixed Callback Segfault in the python coupling

---
 AUTHORS.txt                            |  1 +
 src/python_coupling/PythonCallback.cpp | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS.txt
index 2f956f1b1..3f808a99d 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -31,6 +31,7 @@ Matthias Markl
 Michael Kuron
 Nils Kohl
 Paulo Carvalho
+Philipp Suffa
 Regina Ammer
 Sagar Dolas
 Sebastian Eibl
diff --git a/src/python_coupling/PythonCallback.cpp b/src/python_coupling/PythonCallback.cpp
index 61ef6a1cc..922b1dedd 100644
--- a/src/python_coupling/PythonCallback.cpp
+++ b/src/python_coupling/PythonCallback.cpp
@@ -87,10 +87,11 @@ namespace python_coupling {
 
 
    PythonCallback::PythonCallback( const std::string & fileOrModuleName, const std::string & functionName, const std::vector<std::string> & argv )
-      : functionName_( functionName ), exposedVars_( new DictWrapper() ), callbackDict_( new DictWrapper() )
+      : functionName_( functionName )
    {
       Manager::instance()->triggerInitialization();
-
+      exposedVars_ = make_shared<DictWrapper>();
+      callbackDict_ = make_shared<DictWrapper>();
       namespace py = pybind11;
 
       // Add empty callbacks module
@@ -102,10 +103,11 @@ namespace python_coupling {
 
 
    PythonCallback::PythonCallback( const std::string & functionName )
-      : functionName_( functionName ), exposedVars_( new DictWrapper() ), callbackDict_( new DictWrapper() )
+      : functionName_( functionName )
    {
       Manager::instance()->triggerInitialization();
-
+      exposedVars_ = make_shared<DictWrapper>();
+      callbackDict_ = make_shared<DictWrapper>();
       // Add empty callbacks module
       py::object callbackModule = py::module::import( "walberla_cpp.callbacks");
 
-- 
GitLab