Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix view controller not being released #8

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions PreviewExtension/PreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ class PreviewViewController: NSViewController, QLPreviewingController, WKUIDeleg
}

deinit {
log.debug("deinit PreviewViewController")
log.debug("deinit \(self)")
}

override func loadView() {
log.debug("loadView")
log.debug("\(self) loadView")
view = webView

webView.uiDelegate = self
Expand Down Expand Up @@ -168,6 +168,13 @@ class PreviewViewController: NSViewController, QLPreviewingController, WKUIDeleg
webView.loadFileURL(configuration.pageURL, allowingReadAccessTo: configuration.pageURL)
}

override func viewDidDisappear() {
super.viewDidDisappear()
// Break a strong reference that prevents the view controller from being released
// https://forums.developer.apple.com/forums/thread/713062?answerId=726937022#726937022
webView.configuration.userContentController.removeAllScriptMessageHandlers()
}

func preparePreviewOfFile(at url: URL, completionHandler: @escaping (Error?) -> Void) {
log.info("begin preparing file", metadata: ["url": "\(url)"])
assert(previewedFileURL == nil)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quicklookjs",
"version": "1.0.0",
"version": "1.0.1",
"description": "Quick Look plugin for web-based previews",
"homepage": "https://github.com/jtbandes/quicklookjs#readme",
"author": "Jacob Bandes-Storch",
Expand Down