summary refs log tree commit diff
path: root/src/Cache.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-10-21 21:17:01 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-10-21 21:17:01 +0300
commit160fe1d668d9c1fa8f089cec34df29c2ba31a56f (patch)
treef0d9fd1aee271afa8e51aea312ad1ec01ff614dc /src/Cache.cc
parentRemove ui flickering when adding new timeline events (diff)
downloadnheko-160fe1d668d9c1fa8f089cec34df29c2ba31a56f.tar.xz
Remove cache updates from the main thread
Diffstat (limited to 'src/Cache.cc')
-rw-r--r--src/Cache.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Cache.cc b/src/Cache.cc

index 3f7b141b..010b4aa9 100644 --- a/src/Cache.cc +++ b/src/Cache.cc
@@ -102,14 +102,21 @@ Cache::setState(const QString &nextBatchToken, const QMap<QString, RoomState> &s if (!isMounted_) return; - auto txn = lmdb::txn::begin(env_); + try { + auto txn = lmdb::txn::begin(env_); - setNextBatchToken(txn, nextBatchToken); + setNextBatchToken(txn, nextBatchToken); - for (auto it = states.constBegin(); it != states.constEnd(); it++) - insertRoomState(txn, it.key(), it.value()); + for (auto it = states.constBegin(); it != states.constEnd(); it++) + insertRoomState(txn, it.key(), it.value()); - txn.commit(); + txn.commit(); + } catch (const lmdb::error &e) { + qCritical() << "The cache couldn't be updated: " << e.what(); + + unmount(); + deleteData(); + } } void