protect document against nested recomputes
+ convert ObjectStatusLocker into a template class to make its usage more flexible + add status flag 'Recomputing' and set in Document::recompute to detect and avoid nested calls of recompute
This commit is contained in:
@@ -2007,6 +2007,11 @@ void Document::renameObjectIdentifiers(const std::map<App::ObjectIdentifier, App
|
||||
#ifdef USE_OLD_DAG
|
||||
int Document::recompute()
|
||||
{
|
||||
if (testStatus(Document::Recomputing)) {
|
||||
// this is clearly a bug in the calling instance
|
||||
throw Base::RuntimeError("Nested recomputes of a document are not allowed");
|
||||
}
|
||||
|
||||
int objectCount = 0;
|
||||
|
||||
// The 'SkipRecompute' flag can be (tmp.) set to avoid to many
|
||||
@@ -2015,6 +2020,8 @@ int Document::recompute()
|
||||
if (skip)
|
||||
return 0;
|
||||
|
||||
ObjectStatusLocker<Document::Status, Document> exe(Document::Recomputing, this);
|
||||
|
||||
// delete recompute log
|
||||
for (std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it)
|
||||
delete *it;
|
||||
|
||||
Reference in New Issue
Block a user