[sequence] The store checksum takes the storage into account

This fixed the following scenario:
Create f(x)=120
Create u(n) = f(1)
Go to sequence graph, then Home, then change f.
Go back to the sequence app: the cursor is not updated.
This commit is contained in:
Léa Saviot
2018-11-22 10:17:38 +01:00
committed by Émilie Feral
parent 916493a4d2
commit 5deef3176e

View File

@@ -1,22 +1,25 @@
#include "sequence_store.h"
#include <ion/storage.h>
extern "C" {
#include <assert.h>
#include <stddef.h>
}
#include <ion.h>
namespace Sequence {
constexpr const char * SequenceStore::k_sequenceNames[MaxNumberOfSequences];
uint32_t SequenceStore::storeChecksum() {
size_t dataLengthInBytes = MaxNumberOfSequences*sizeof(uint32_t);
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
assert((MaxNumberOfSequences*sizeof(uint32_t) & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
uint32_t checksums[MaxNumberOfSequences];
for (int i = 0; i < MaxNumberOfSequences; i++) {
checksums[i] = m_sequences[i].checksum();
}
return Ion::crc32((uint32_t *)checksums, dataLengthInBytes/sizeof(uint32_t));
constexpr int checksumsStoreStorageSize = 2;
uint32_t checksumsStoreStorage[checksumsStoreStorageSize];
checksumsStoreStorage[0] = Ion::crc32((uint32_t *)checksums, MaxNumberOfSequences);
checksumsStoreStorage[1] = Ion::Storage::sharedStorage()->checksum();
return Ion::crc32((uint32_t *)checksumsStoreStorage, checksumsStoreStorageSize);
}
char SequenceStore::symbol() const {