aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2024-02-15 15:36:39 +0100
committerRobin Jarry <robin@jarry.cc>2024-02-15 15:57:00 +0100
commit46ea87602c092750984307e4f31200ad3b9d7fe4 (patch)
treec9f024bc1ed0d49776afda592edc5fdbc18d4af3
parentd56e949a339d61da2cc7fc20ce0bf19dadf0095d (diff)
downloadaerc-46ea87602c092750984307e4f31200ad3b9d7fe4.tar.gz
aerc-46ea87602c092750984307e4f31200ad3b9d7fe4.zip
store: fix split view blinking
When split view and threading mode are enabled, the message is blinking. First, since commit ddfa5cac1fe9 ("msgstore: fix deadlock in thread builder"), the threadCallback is never set to nil: the thread builder calls it continuously. After setting it to nil, the message is still blinking once. To avoid this, don't call the onSelect method (which points to AccountView.updateSplitView()) from the thread builder: the message is already displayed. Let's rewrite Select and selectPriv: - Select(): it takes the lock and calls the onSelect callback; - selectPriv: the assumption is that the lock is held. It doesn't call the onSelect callback. This function is only used by the thread builder. Fixes: 588be1a28422 ("store: improve cursor position") Fixes: ddfa5cac1fe9 ("msgstore: fix deadlock in thread builder") Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--lib/msgstore.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 33daa9ff..274e42ba 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -718,22 +718,26 @@ func (store *MessageStore) SelectedUid() uint32 {
}
func (store *MessageStore) Select(uid uint32) {
- store.threadsMutex.Lock()
- if store.threadCallback != nil {
- store.threadCallback = nil
+ store.selectPriv(uid, false)
+ if store.onSelect != nil {
+ store.onSelect(store.Selected())
}
- store.threadsMutex.Unlock()
- store.selectPriv(uid)
}
-func (store *MessageStore) selectPriv(uid uint32) {
+func (store *MessageStore) selectPriv(uid uint32, lockHeld bool) {
+ if !lockHeld {
+ store.threadsMutex.Lock()
+ }
+ if store.threadCallback != nil {
+ store.threadCallback = nil
+ }
+ if !lockHeld {
+ store.threadsMutex.Unlock()
+ }
store.selectedUid = uid
if store.marker != nil {
store.marker.UpdateVisualMark()
}
- if store.onSelect != nil {
- store.onSelect(store.Selected())
- }
}
func (store *MessageStore) NextPrev(delta int) {
@@ -761,7 +765,7 @@ func (store *MessageStore) NextPrev(delta int) {
store.threadsMutex.Lock()
store.threadCallback = func() {
if uids := store.Uids(); len(uids) > newIdx {
- store.selectPriv(uids[newIdx])
+ store.selectPriv(uids[newIdx], true)
}
}
store.threadsMutex.Unlock()