fix: app would sometimes crash on macos monterey (closes #5051)

This commit is contained in:
lwouis committed 2025-11-24 11:19:44 +01:00
1 parent 2c3373ae16
commit 29e1cff8f1
1 file changed
+5 -8
+5 -8
View File
@@ -1,7 +1,7 @@
import Cocoa import Cocoa
class ThumbnailsView { class ThumbnailsView {
let scrollView = ScrollView() var scrollView: ScrollView!
var contentView: EffectView! var contentView: EffectView!
static var recycledViews = [ThumbnailView]() static var recycledViews = [ThumbnailView]()
var rows = [[ThumbnailView]]() var rows = [[ThumbnailView]]()
@@ -9,18 +9,15 @@ class ThumbnailsView {
static var thumbnailsHeight = CGFloat(0.0) static var thumbnailsHeight = CGFloat(0.0)
init() { init() {
contentView = makeAppropriateEffectView() updateBackgroundView()
contentView.addSubview(scrollView)
// TODO: think about this optimization more // TODO: think about this optimization more
(1...20).forEach { _ in ThumbnailsView.recycledViews.append(ThumbnailView()) } (1...20).forEach { _ in ThumbnailsView.recycledViews.append(ThumbnailView()) }
} }
func updateBackgroundView() { func updateBackgroundView() {
let newEffectView = makeAppropriateEffectView() contentView = makeAppropriateEffectView()
scrollView.removeFromSuperview() scrollView = ScrollView()
newEffectView.addSubview(scrollView) contentView.addSubview(scrollView)
contentView.superview?.replaceSubview(contentView, with: newEffectView)
contentView = newEffectView
} }
func reset() { func reset() {