Skip to content

Commit 29e1cff

Browse files
committed
fix: app would sometimes crash on macos monterey (closes #5051)
1 parent 2c3373a commit 29e1cff

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/ui/main-window/ThumbnailsView.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
import Cocoa
22

33
class ThumbnailsView {
4-
let scrollView = ScrollView()
4+
var scrollView: ScrollView!
55
var contentView: EffectView!
66
static var recycledViews = [ThumbnailView]()
77
var rows = [[ThumbnailView]]()
88
static var thumbnailsWidth = CGFloat(0.0)
99
static var thumbnailsHeight = CGFloat(0.0)
1010

1111
init() {
12-
contentView = makeAppropriateEffectView()
13-
contentView.addSubview(scrollView)
12+
updateBackgroundView()
1413
// TODO: think about this optimization more
1514
(1...20).forEach { _ in ThumbnailsView.recycledViews.append(ThumbnailView()) }
1615
}
1716

1817
func updateBackgroundView() {
19-
let newEffectView = makeAppropriateEffectView()
20-
scrollView.removeFromSuperview()
21-
newEffectView.addSubview(scrollView)
22-
contentView.superview?.replaceSubview(contentView, with: newEffectView)
23-
contentView = newEffectView
18+
contentView = makeAppropriateEffectView()
19+
scrollView = ScrollView()
20+
contentView.addSubview(scrollView)
2421
}
2522

2623
func reset() {

0 commit comments

Comments
 (0)