From 75b55658a755a8fcc50d53bfe7e088ea104fda36 Mon Sep 17 00:00:00 2001 From: Kevin Martin Date: Mon, 31 Mar 2025 15:52:05 -0400 Subject: [PATCH] Check for a null scene object Under certain unusual circumstances getSceneGraph can be called when the scene is null, causing a native exception when the scene's reference count is incremented. This changes the code to return python None in this condition, allowing the calling cod eto handle the no-scene case itself. --- src/Gui/View3DPy.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index dab66a874b..30eaf2a56a 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -2135,6 +2135,9 @@ Py::Object View3DInventorPy::getSceneGraph() { try { SoNode* scene = getView3DInventorPtr()->getViewer()->getSceneGraph(); + if (scene == nullptr) { + return Py::None(); + } PyObject* proxy = nullptr; proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", static_cast(scene), 1); scene->ref();