From bb9b5ba38e647c59d00b74293251c47f0add376c Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 13 Aug 2017 11:04:18 +0200 Subject: [PATCH] in PropertyLinkList replace assert with C++ exception to avoid a crash --- src/App/PropertyLinks.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index cb92d0621c..679315f013 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -24,7 +24,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +# include +# include #endif /// Here the FreeCAD includes sorted by Base,App,Gui...... @@ -309,7 +310,15 @@ void PropertyLinkList::Restore(Base::XMLReader &reader) reader.readElement("LinkList"); // get the value of my attribute int count = reader.getAttributeAsInteger("count"); - assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())); + App::PropertyContainer* container = getContainer(); + if (!container) + throw Base::RuntimeError("Property is not part of a container"); + if (!container->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) { + std::stringstream str; + str << "Container is not a document object (" + << container->getTypeId().getName() << ")"; + throw Base::TypeError(str.str()); + } std::vector values; values.reserve(count);