[shared] Create ExpiringPointer: in DEBUG, check that pointers to

memoized functions are not used when invalid
This commit is contained in:
Émilie Feral
2018-10-23 17:46:15 +02:00
parent 8e6cff9572
commit e8b58a2b5b
29 changed files with 108 additions and 49 deletions

View File

@@ -41,7 +41,7 @@ float GraphController::interestingXRange() {
float characteristicRange = 0.0f;
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
StorageFunction * f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
ExpiringPointer<StorageCartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
float fRange = f->expression(myApp->localContext()).characteristicXRange(*(myApp->localContext()), Poincare::Preferences::sharedPreferences()->angleUnit());
if (!std::isnan(fRange)) {
characteristicRange = fRange > characteristicRange ? fRange : characteristicRange;
@@ -56,7 +56,7 @@ int GraphController::estimatedBannerNumberOfLines() const {
void GraphController::selectFunctionWithCursor(int functionIndex) {
StorageFunctionGraphController::selectFunctionWithCursor(functionIndex);
StorageCartesianFunction * f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor()));
ExpiringPointer<StorageCartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor()));
m_cursorView.setColor(f->color());
}