Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae807e1d authored by Hans Boehm's avatar Hans Boehm
Browse files

Force reevaluation if mChangedValue is true

Bug: 22481292

This could result in display of an old result.

Factor out code to start a result evaluation.

Change-Id: I651d4386323c0abd7a86176b386072093345a1b1
parent 0b9806f6
Loading
Loading
Loading
Loading
+15 −8
Original line number Original line Diff line number Diff line
@@ -787,6 +787,18 @@ class Evaluator {
        clearCache();
        clearCache();
    }
    }


    /**
     * Start asynchronous result evaluation of formula.
     * Will result in display on completion.
     * @param required result was explicitly requested by user.
     */
    private void reevaluateResult(boolean required) {
        clearCache();
        mEvaluator = new AsyncDisplayResult(mDegreeMode, required);
        mEvaluator.execute();
        mChangedValue = false;
    }

    // Begin evaluation of result and display when ready.
    // Begin evaluation of result and display when ready.
    // We assume this is called after each insertion and deletion.
    // We assume this is called after each insertion and deletion.
    // Thus if we are called twice with the same effective end of
    // Thus if we are called twice with the same effective end of
@@ -796,13 +808,10 @@ class Evaluator {
            // Already done or in progress.
            // Already done or in progress.
            return;
            return;
        }
        }
        clearCache();
        // In very odd cases, there can be significant latency to evaluate.
        // In very odd cases, there can be significant latency to evaluate.
        // Don't show obsolete result.
        // Don't show obsolete result.
        mResult.clear();
        mResult.clear();
        mEvaluator = new AsyncDisplayResult(mDegreeMode, false);
        reevaluateResult(false);
        mEvaluator.execute();
        mChangedValue = false;
    }
    }


    // Ensure that we either display a result or complain.
    // Ensure that we either display a result or complain.
@@ -810,12 +819,10 @@ class Evaluator {
    // We presume that any prior result was computed using the same
    // We presume that any prior result was computed using the same
    // expression.
    // expression.
    void requireResult() {
    void requireResult() {
        if (mCache == null) {
        if (mCache == null || mChangedValue) {
            // Restart evaluator in requested mode, i.e. with longer timeout.
            // Restart evaluator in requested mode, i.e. with longer timeout.
            cancelAll(true);
            cancelAll(true);
            clearCache();
            reevaluateResult(true);
            mEvaluator = new AsyncDisplayResult(mDegreeMode, true);
            mEvaluator.execute();
        } else {
        } else {
            // Notify immediately, reusing existing result.
            // Notify immediately, reusing existing result.
            int dotPos = mCache.indexOf('.');
            int dotPos = mCache.indexOf('.');