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:
wmayer
2017-07-17 18:24:10 +02:00
parent d3f5ace928
commit 033242ead8
6 changed files with 26 additions and 11 deletions

View File

@@ -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;