[apps/variable_box_controller] Fix expressionLayoutForRecord

This commit is contained in:
Léa Saviot
2020-02-21 16:33:11 +01:00
committed by EmilieNumworks
parent 8fe41a8673
commit 686e25ec43

View File

@@ -236,20 +236,20 @@ Layout VariableBoxController::expressionLayoutForRecord(Storage::Record record,
assert(m_firstMemoizedLayoutIndex >= 0);
}
assert(index >= m_firstMemoizedLayoutIndex && index < m_firstMemoizedLayoutIndex + k_maxNumberOfDisplayedRows);
Layout result;
if (m_layouts[index-m_firstMemoizedLayoutIndex].isUninitialized()) {
/* Creating the layout of a very long variable might throw a pool exception.
* We want to catch it and return a dummy layout instead, otherwise the user
* won't be able to open the variable box again, until she deletes the
* problematic variable -> and she has no help to remember its name, as she
* can't open the variable box. */
Layout result;
Poincare::ExceptionCheckpoint ecp;
if (ExceptionRun(ecp)) {
result = GlobalContext::LayoutForRecord(record);
}
m_layouts[index-m_firstMemoizedLayoutIndex] = result;
}
m_layouts[index-m_firstMemoizedLayoutIndex] = result;
return result;
return m_layouts[index-m_firstMemoizedLayoutIndex];
}
const char * VariableBoxController::extension() const {