Spreadsheet: improve cyclic dependency exception handling

This commit is contained in:
Zheng, Lei
2019-09-29 17:57:23 +08:00
committed by wmayer
parent 44354b808b
commit 976952db63
3 changed files with 15 additions and 13 deletions

View File

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

View File

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

View File

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