From fedbd2fc2ebda22bce65433c148c77d0d02635d9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Aug 2014 17:47:50 +0200 Subject: [PATCH] + Check for valid document in link properties --- src/App/PropertyLinks.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index a41198996..ee608a704 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -131,7 +131,8 @@ void PropertyLink::Restore(Base::XMLReader &reader) if (name != "") { DocumentObject* parent = static_cast(getContainer()); - DocumentObject* object = parent->getDocument()->getObject(name.c_str()); + App::Document* document = parent->getDocument(); + DocumentObject* object = document ? document->getObject(name.c_str()) : 0; if (!object) { Base::Console().Warning("Lost link to '%s' while loading, maybe " "an object was not loaded correctly\n",name.c_str()); @@ -316,8 +317,8 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) DocumentObject *pcObject; if (name != ""){ - pcObject = static_cast(getContainer())-> - getDocument()->getObject(name.c_str()); + App::Document* document = static_cast(getContainer())->getDocument(); + pcObject = document ? document->getObject(name.c_str()) : 0; if (!pcObject) Base::Console().Warning("Lost link to '%s' while loading, maybe " "an object was not loaded correctly\n",name.c_str()); @@ -466,7 +467,8 @@ void PropertyLinkList::Restore(Base::XMLReader &reader) // document. Thus, we should silently ingore this. // Property not in an object! DocumentObject* father = static_cast(getContainer()); - DocumentObject* child = father->getDocument()->getObject(name.c_str()); + App::Document* document = father->getDocument(); + DocumentObject* child = document ? document->getObject(name.c_str()) : 0; if (child) values.push_back(child); else @@ -657,7 +659,8 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader) // document. Thus, we should silently ingore this. // Property not in an object! DocumentObject* father = static_cast(getContainer()); - DocumentObject* child = father->getDocument()->getObject(name.c_str()); + App::Document* document = father->getDocument(); + DocumentObject* child = document ? document->getObject(name.c_str()) : 0; if (child) values.push_back(child); else