aboutsummaryrefslogtreecommitdiffstats
path: root/i_events.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-10 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-10 20:20:20 +0100
commit1588dd32255eb2ce6810a691c898bc6c8258aebe (patch)
tree014483e1eb9f7b7f9a249f47945e815b3abbef8a /i_events.go
parentcleanup (diff)
downloadhardflip-1588dd32255eb2ce6810a691c898bc6c8258aebe.tar.gz
hardflip-1588dd32255eb2ce6810a691c898bc6c8258aebe.tar.bz2
hardflip-1588dd32255eb2ce6810a691c898bc6c8258aebe.tar.xz
hardflip-1588dd32255eb2ce6810a691c898bc6c8258aebe.tar.zst
hardflip-1588dd32255eb2ce6810a691c898bc6c8258aebe.zip
fixed segv
Diffstat (limited to '')
-rw-r--r--i_events.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/i_events.go b/i_events.go
index c414eca..177914e 100644
--- a/i_events.go
+++ b/i_events.go
@@ -81,10 +81,14 @@ func i_unfold_dir(data *HardData, item *ItemsNode) {
if fold == nil {
return
}
- after := item.next
- item.next = fold.head
- fold.head.prev = item
- fold.last.next = after
+ after := item.next // nil
+ item.next = fold.head // nil
+ if fold.head != nil {
+ fold.head.prev = item
+ }
+ if fold.last != nil {
+ fold.last.next = after
+ }
if after != nil {
after.prev = fold.last
} else {
@@ -95,21 +99,31 @@ func i_unfold_dir(data *HardData, item *ItemsNode) {
ptr.next.ID = ptr.ID + 1
}
item.Dirs.Folded = false
+ // FIX: segv close last empty folder
}
func i_fold_dir(data *HardData, item *ItemsNode) {
if item == nil || item.Dirs == nil {
return
}
+ var folded_start, folded_end, after *ItemsNode
folds := data.folds
- folded_start := item.next
- folded_start.prev = nil
- folded_end := item
- for i := 0; i < item.Dirs.count_elements(true) && folded_end != nil; i++ {
+ folded_start = item.next
+ if folded_start != nil {
+ folded_start.prev = nil
+ folded_end = item
+ } else {
+ folded_end = nil
+ }
+ for i := 0; folded_end != nil && i < item.Dirs.count_elements(true); i++ {
folded_end = folded_end.next
}
- after := folded_end.next
- folded_end.next = nil
+ if folded_end != nil {
+ after = folded_end.next
+ folded_end.next = nil
+ } else {
+ after = nil
+ }
tmp := ItemsList{
folded_start,
folded_end,