From 6229f7deafec7fe0e8a1a891a0a86d3da0069715 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 25 Nov 2022 12:54:24 +0800 Subject: [PATCH] CtlCandidateTDK // Memory leak fix, etc. - Also stop reloadData() on init(). --- .../CandidateWindow/CandidatePool.swift | 14 ++-- .../TDKCandidates/CtlCandidateTDK.swift | 83 +++++++++---------- .../VwrCandidateHorizontal.swift | 10 +-- .../VwrCandidateVertical.swift | 10 +-- .../VwrCandidateHorizontalBackports.swift | 12 +-- .../VwrCandidateVerticalBackports.swift | 12 +-- 6 files changed, 68 insertions(+), 73 deletions(-) diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift index 6be973b0..2b15cc3c 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift @@ -10,7 +10,7 @@ import Cocoa import Shared /// 候選字窗會用到的資料池單位。 -public class CandidatePool { +public struct CandidatePool { public let blankCell = CandidateCellData(key: " ", displayedText: " ", isSelected: false) public var currentLayout: NSUserInterfaceLayoutOrientation = .horizontal public private(set) var candidateDataAll: [CandidateCellData] = [] @@ -174,7 +174,7 @@ public class CandidatePool { // MARK: Public Functions - public func selectNewNeighborLine(isForward: Bool) { + public mutating func selectNewNeighborLine(isForward: Bool) { switch currentLayout { case .horizontal: selectNewNeighborRow(direction: isForward ? .down : .up) case .vertical: selectNewNeighborColumn(direction: isForward ? .right : .left) @@ -182,7 +182,7 @@ public class CandidatePool { } } - public func highlight(at indexSpecified: Int) { + public mutating func highlight(at indexSpecified: Int) { switch currentLayout { case .horizontal: highlightHorizontal(at: indexSpecified) case .vertical: highlightVertical(at: indexSpecified) @@ -221,7 +221,7 @@ extension CandidatePool { currentColumnNumber..