Spreadsheet: improve cyclic dependency exception handling
This commit is contained in:
@@ -585,9 +585,9 @@ bool Cell::getSpans(int &rows, int &columns) const
|
||||
return isUsed(SPANS_SET);
|
||||
}
|
||||
|
||||
void Cell::setException(const std::string &e)
|
||||
void Cell::setException(const std::string &e, bool silent)
|
||||
{
|
||||
if(e.size() && owner && owner->sheet()) {
|
||||
if(!silent && e.size() && owner && owner->sheet()) {
|
||||
FC_ERR(owner->sheet()->getFullName() << '.'
|
||||
<< address.toString() << ": " << e);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
void setSpans(int rows, int columns);
|
||||
bool getSpans(int & rows, int & columns) const;
|
||||
|
||||
void setException(const std::string & e);
|
||||
void setException(const std::string & e, bool silent=false);
|
||||
|
||||
void clearException();
|
||||
|
||||
|
||||
@@ -858,15 +858,15 @@ DocumentObjectExecReturn *Sheet::execute(void)
|
||||
FC_LOG(addr.toString());
|
||||
recomputeCell(addr);
|
||||
}
|
||||
} catch (std::exception&) {
|
||||
} catch (std::exception &) {
|
||||
for(auto &v : VertexList) {
|
||||
Cell * cell = cells.getValue(v.first);
|
||||
// Mark as erroneous
|
||||
cellErrors.insert(v.first);
|
||||
if (cell)
|
||||
cell->setException("Pending computation due to cyclic dependency");
|
||||
updateProperty(v.first);
|
||||
updateAlias(v.first);
|
||||
if(cell) {
|
||||
cellErrors.insert(v.first);
|
||||
cell->setException("Pending computation due to cyclic dependency",true);
|
||||
cellUpdated(v.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to be more user friendly by finding individual loops
|
||||
@@ -912,10 +912,10 @@ DocumentObjectExecReturn *Sheet::execute(void)
|
||||
} catch (std::exception&) {
|
||||
// Cycle detected; flag all with errors
|
||||
std::ostringstream ss;
|
||||
ss << "Cyclic dependency" << std::endl;
|
||||
ss << "Cyclic dependency";
|
||||
int count = 0;
|
||||
for(auto &v : VertexList) {
|
||||
if(count==20)
|
||||
if(count++%20 == 0)
|
||||
ss << std::endl;
|
||||
else
|
||||
ss << ", ";
|
||||
@@ -924,8 +924,10 @@ DocumentObjectExecReturn *Sheet::execute(void)
|
||||
std::string msg = ss.str();
|
||||
for(auto &v : VertexList) {
|
||||
Cell * cell = cells.getValue(v.first);
|
||||
if (cell)
|
||||
cell->setException(msg.c_str());
|
||||
if (cell) {
|
||||
cell->setException(msg.c_str(),true);
|
||||
cellUpdated(v.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user