🐛 Alt+Click the heading folding triangle causing hang https://github.com/siyuan-note/siyuan/issues/10339

This commit is contained in:
Daniel 2024-02-07 23:37:06 +08:00
parent 351cc9ce25
commit 1c8e9c3f25
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -176,7 +176,7 @@ func performTx(tx *Transaction) (ret *TxErr) {
msg := fmt.Sprintf("PANIC RECOVERED: %v\n\t%s\n", e, stack)
logging.LogErrorf(msg)
if 0 == tx.state.Load() {
if 1 == tx.state.Load() {
tx.rollback()
return
}
@ -1250,12 +1250,12 @@ type Transaction struct {
luteEngine *lute.Lute
m *sync.Mutex
state atomic.Int32 // 0: 未提交1: 已提交2: 已回滚
state atomic.Int32 // 0: 初始化1未提交:2: 已提交3: 已回滚
}
func (tx *Transaction) WaitForCommit() {
for {
if 0 == tx.state.Load() {
if 1 == tx.state.Load() {
time.Sleep(10 * time.Millisecond)
continue
}
@ -1271,7 +1271,7 @@ func (tx *Transaction) begin() (err error) {
tx.nodes = map[string]*ast.Node{}
tx.luteEngine = util.NewLute()
tx.m.Lock()
tx.state.Store(0)
tx.state.Store(1)
return
}
@ -1284,14 +1284,14 @@ func (tx *Transaction) commit() (err error) {
refreshDynamicRefTexts(tx.nodes, tx.trees)
IncSync()
tx.trees = nil
tx.state.Store(1)
tx.state.Store(2)
tx.m.Unlock()
return
}
func (tx *Transaction) rollback() {
tx.trees, tx.nodes = nil, nil
tx.state.Store(2)
tx.state.Store(3)
tx.m.Unlock()
return
}