Extensions: Handle new dynamic_cast's

This commit is contained in:
Stefan Tröger
2016-09-04 17:42:26 +02:00
committed by wmayer
parent ab692a4c08
commit 258be36aad
13 changed files with 83 additions and 52 deletions

View File

@@ -1894,14 +1894,15 @@ DocumentObject * Document::addObject(const char* sType, const char* pObjectName,
string ObjectName;
if (!base)
return 0;
if (!base->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) {
App::DocumentObject* pcObject = dynamic_cast<App::DocumentObject*>(base);
if (!pcObject) {
delete base;
std::stringstream str;
str << "'" << sType << "' is not a document object type";
throw Base::TypeError(str.str());
}
App::DocumentObject* pcObject = dynamic_cast<App::DocumentObject*>(base);
pcObject->setDocument(this);
// do no transactions if we do a rollback!