Skip to content

Commit

Permalink
Omit calling UserDefaultsObservation.invalidate() in deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Jun 28, 2020
1 parent 5732aa7 commit 57b605d
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 57 deletions.
2 changes: 2 additions & 0 deletions CotEditor/Sources/DefaultKey+Observation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extension UserDefaults {

/// Register the observer object to observe UserDefaults value change.
///
/// You don't need to invalidate an observer in its `deinit` method.
///
/// - Parameters:
/// - key: The typed UserDefaults key to obseve the change of its value.
/// - queue: The operation queue where to perform the `changeHandler`.
Expand Down
1 change: 0 additions & 1 deletion CotEditor/Sources/DocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ final class DocumentViewController: NSSplitViewController, SyntaxParserDelegate,

deinit {
self.appearanceObserver?.invalidate()
self.defaultsObservers.forEach { $0.invalidate() }
}


Expand Down
9 changes: 0 additions & 9 deletions CotEditor/Sources/DocumentWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ final class DocumentWindowController: NSWindowController {


// MARK: -
// MARK: Lifecycle

deinit {
self.windowAlphaObserver?.invalidate()
self.appearanceModeObserver?.invalidate()
}



// MARK: Window Controller Methods

/// prepare window
Expand Down
1 change: 0 additions & 1 deletion CotEditor/Sources/EditorTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ final class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, URLDe
deinit {
self.insertionPointTimer?.cancel()
self.urlDetectionQueue.cancelAllOperations()
self.defaultsObservers.forEach { $0.invalidate() }

if let observer = self.windowOpacityObserver {
NotificationCenter.default.removeObserver(observer)
Expand Down
5 changes: 0 additions & 5 deletions CotEditor/Sources/EncodingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ final class EncodingManager: NSObject {
}


deinit {
self.encodingListObserver?.invalidate()
}



// MARK: Public Methods

Expand Down
10 changes: 1 addition & 9 deletions CotEditor/Sources/FindPanelButtonViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2014-2019 1024jp
// © 2014-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,14 +36,6 @@ final class FindPanelButtonViewController: NSViewController {


// MARK: -
// MARK: Lifecycle

deinit {
self.findNextAfterReplaceObserver?.invalidate()
}



// MARK: View Controller Methods

/// setup UI
Expand Down
1 change: 0 additions & 1 deletion CotEditor/Sources/FindPanelFieldViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ final class FindPanelFieldViewController: NSViewController, NSTextViewDelegate {

deinit {
self.scrollerStyleObserver?.invalidate()
self.defaultsObservers.forEach { $0.invalidate() }
}


Expand Down
6 changes: 0 additions & 6 deletions CotEditor/Sources/FindPanelLayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ final class FindPanelLayoutManager: NSLayoutManager, NSLayoutManagerDelegate, In
}


deinit {
self.invisiblesDefaultsObservers.forEach { $0.invalidate() }
self.invisibleVisibilityObserver?.invalidate()
}



// MARK: Layout Manager Methods

Expand Down
6 changes: 0 additions & 6 deletions CotEditor/Sources/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ final class LayoutManager: NSLayoutManager, InvisibleDrawing, ValidationIgnorabl
}


deinit {
self.invisiblesDefaultsObservers.forEach { $0.invalidate() }
self.indentGuideObserver?.invalidate()
}



// MARK: Layout Manager Methods

Expand Down
2 changes: 0 additions & 2 deletions CotEditor/Sources/OutlineViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ final class OutlineViewController: NSViewController {
if let observer = self.selectionObserver {
NotificationCenter.default.removeObserver(observer)
}

self.fontSizeObserver?.invalidate()
}


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


// MARK: -
// MARK: Lifecycle

deinit {
self.defaultsObservers.forEach { $0.invalidate() }
}



// MARK: View Controller Methods

/// setup
Expand Down
10 changes: 1 addition & 9 deletions CotEditor/Sources/ToolbarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ---------------------------------------------------------------------------
//
// © 2004-2007 nakamuxu
// © 2014-2019 1024jp
// © 2014-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,14 +105,6 @@ final class ToolbarController: NSObject {


// MARK: -
// MARK: Lifecycle

deinit {
self.recentStyleNamesObserver?.invalidate()
}



// MARK: Object Methods

override func awakeFromNib() {
Expand Down

0 comments on commit 57b605d

Please sign in to comment.