Skip to content

Commit

Permalink
Explicitly cancel observations in LineEndingScanner (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Jun 27, 2024
1 parent f55ab6c commit 781e9fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CotEditor/Sources/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
super.close()

self.textStorageObserver?.cancel()
self.lineEndingScanner.cancel()
self.analyzer.cancel()
}

Expand Down
8 changes: 8 additions & 0 deletions CotEditor/Sources/LineEndingScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ final class LineEndingScanner {

// MARK: Public Methods

/// Cancels all observations.
func cancel() {

self.lineEndingObserver?.cancel()
self.storageObserver?.cancel()
}


/// The line endings mostly occurred in the storage.
var majorLineEnding: LineEnding? {

Expand Down

0 comments on commit 781e9fd

Please sign in to comment.