Commit da2d3644 authored by wmayer's avatar wmayer
Browse files

protect document against nested recomputes

parent 7a0bc376
...@@ -144,6 +144,7 @@ struct DocumentP ...@@ -144,6 +144,7 @@ struct DocumentP
bool rollback; bool rollback;
bool closable; bool closable;
bool keepTrailingDigits; bool keepTrailingDigits;
bool recomputeNow;
int iUndoMode; int iUndoMode;
unsigned int UndoMemSize; unsigned int UndoMemSize;
unsigned int UndoMaxStackSize; unsigned int UndoMaxStackSize;
...@@ -159,6 +160,7 @@ struct DocumentP ...@@ -159,6 +160,7 @@ struct DocumentP
rollback = false; rollback = false;
closable = true; closable = true;
keepTrailingDigits = true; keepTrailingDigits = true;
recomputeNow = false;
iUndoMode = 0; iUndoMode = 0;
UndoMemSize = 0; UndoMemSize = 0;
UndoMaxStackSize = 20; UndoMaxStackSize = 20;
...@@ -1720,6 +1722,12 @@ void Document::_rebuildDependencyList(void) ...@@ -1720,6 +1722,12 @@ void Document::_rebuildDependencyList(void)
void Document::recompute() void Document::recompute()
{ {
if (d->recomputeNow) {
throw Base::RuntimeError("Nested recomputes of a document are not allowed");
}
d->recomputeNow = true;
// delete recompute log // delete recompute log
for( std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it) for( std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it)
delete *it; delete *it;
...@@ -1738,6 +1746,7 @@ void Document::recompute() ...@@ -1738,6 +1746,7 @@ void Document::recompute()
} }
catch (const std::exception& e) { catch (const std::exception& e) {
std::cerr << "Document::recompute: " << e.what() << std::endl; std::cerr << "Document::recompute: " << e.what() << std::endl;
d->recomputeNow = false;
return; return;
} }
...@@ -1824,6 +1833,7 @@ void Document::recompute() ...@@ -1824,6 +1833,7 @@ void Document::recompute()
d->vertexMap.clear(); d->vertexMap.clear();
signalRecomputed(*this); signalRecomputed(*this);
d->recomputeNow = false;
} }
const char * Document::getErrorDescription(const App::DocumentObject*Obj) const const char * Document::getErrorDescription(const App::DocumentObject*Obj) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment