When restoring a temporary context, account for changes to the context made by actions (typically operators) in the script. There was an incorrect assumption that an override which didn't change the current context would also be unchanged when restoring the temporary context's original values.