From 0d2f7e9cc9860c9a834e0f763094ab09b1bfe98d Mon Sep 17 00:00:00 2001 From: Jared Duffey Date: Thu, 18 Apr 2024 16:17:55 -0400 Subject: [PATCH] Added nullptr check to PipelineFilter name and human_name Signed-off-by: Jared Duffey --- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 80cfc6663f..f3c5a316fe 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -1373,9 +1373,27 @@ PYBIND11_MODULE(simplnx, mod) pipelineFilter.def( "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); pipelineFilter.def( - "name", [](PipelineFilter& self) { return self.getFilter()->name(); }, "Returns the C++ name of the filter"); + "name", + [](const PipelineFilter& self) { + const IFilter* filter = self.getFilter(); + if(filter == nullptr) + { + throw std::runtime_error("PipelineFilter doesn't contain a filter (nullptr)"); + } + return filter->name(); + }, + "Returns the C++ name of the filter"); pipelineFilter.def( - "human_name", [](PipelineFilter& self) { return self.getFilter()->humanName(); }, "Returns the human facing name of the filter"); + "human_name", + [](const PipelineFilter& self) { + const IFilter* filter = self.getFilter(); + if(filter == nullptr) + { + throw std::runtime_error("PipelineFilter doesn't contain a filter (nullptr)"); + } + return filter->humanName(); + }, + "Returns the human facing name of the filter"); py::class_ pyFilter(mod, "PyFilter"); pyFilter.def(py::init<>([](py::object object) { return std::make_unique(std::move(object)); }));