From fdfffbcc9e1e0b5a0ea44bb5f73e6fe937f780a1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Jul 2024 23:26:47 +0200 Subject: [PATCH] TD: Fix DrawViewCollection::unsetupObject() Assigning a null pointer to a std::string causes a failure --- src/Mod/TechDraw/App/DrawViewCollection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewCollection.cpp b/src/Mod/TechDraw/App/DrawViewCollection.cpp index b90498b896..19125afb86 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollection.cpp @@ -213,9 +213,11 @@ void DrawViewCollection::unsetupObject() std::string docName = getDocument()->getName(); for (auto* view : Views.getValues()) { - std::string viewName = view->getNameInDocument(); - Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")", - docName.c_str(), viewName.c_str()); + if (view->isAttachedToDocument()) { + std::string viewName = view->getNameInDocument(); + Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")", + docName.c_str(), viewName.c_str()); + } } std::vector emptyViews;