[shared/continous_function] Detach cache of inactive function

When a function that had previously been cached is deactivated, its
cache can be used by another function. When the function is reactivated,
if it tries to reuse its previous cache, it will be filled with values
from another function, and will not be cleared. By detaching the cache
of a function that becomes inactive, we ensure that the next time this
function is cached, the chache will be cleared.

e.g. Define to functions f(x)=x, g(x)=-x, draw them both.
     Deactivate f, the redraw the graph
     Reactivate f, the draw again
This commit is contained in:
Gabriel Ozouf
2020-12-01 16:13:33 +01:00
committed by LeaNumworks
parent 3501146e35
commit 937979503a
3 changed files with 5 additions and 0 deletions

View File

@@ -50,6 +50,9 @@ KDColor Function::color() const {
void Function::setActive(bool active) {
recordData()->setActive(active);
if (!active) {
functionBecameInactive();
}
}
int Function::printValue(double cursorT, double cursorX, double cursorY, char * buffer, int bufferSize, int precision, Poincare::Context * context) {