part deletion handling

-remove everxthing that belongs to a part on deletion
-disallow to delete the origin by the user and only remove it when Part is being deleted
This commit is contained in:
Stefan Tröger
2015-07-08 07:06:49 +02:00
parent 54dfe5cbff
commit 1ebe3e729c
13 changed files with 455 additions and 11 deletions

View File

@@ -2053,13 +2053,20 @@ void Document::_addObject(DocumentObject* pcObject, const char* pObjectName)
}
/// Remove an object out of the document
void Document::remObject(const char* sName)
void Document::remObject(const char* sName, bool forceIfUndeletable)
{
std::map<std::string,DocumentObject*>::iterator pos = d->objectMap.find(sName);
// name not found?
if (pos == d->objectMap.end())
return;
// undeletable?
if (pos->second->testStatus(ObjectStatus::Undeletable) && !forceIfUndeletable) {
std::stringstream str;
str << "Document object '" << pos->second->getNameInDocument() << "' is undeletable";
throw Base::Exception(str.str());
}
_checkTransaction(pos->second);
@@ -2123,7 +2130,7 @@ void Document::_remObject(DocumentObject* pcObject)
_checkTransaction(pcObject);
std::map<std::string,DocumentObject*>::iterator pos = d->objectMap.find(pcObject->getNameInDocument());
if (d->activeObject == pcObject)
d->activeObject = 0;