Merge pull request #445 from mitchellh/observe-config

macos: AppState config must be published and observed
This commit is contained in:
Mitchell Hashimoto
2023-09-13 15:12:42 -07:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import SwiftUI
import GhosttyKit import GhosttyKit
struct PrimaryView: View { struct PrimaryView: View {
let ghostty: Ghostty.AppState @ObservedObject var ghostty: Ghostty.AppState
// We need access to our app delegate to know if we're quitting or not. // We need access to our app delegate to know if we're quitting or not.
// Make sure to use `@ObservedObject` so we can keep track of `appDelegate.confirmQuit`. // Make sure to use `@ObservedObject` so we can keep track of `appDelegate.confirmQuit`.

View File

@ -23,7 +23,7 @@ extension Ghostty {
/// The ghostty global configuration. This should only be changed when it is definitely /// The ghostty global configuration. This should only be changed when it is definitely
/// safe to change. It is definite safe to change only when the embedded app runtime /// safe to change. It is definite safe to change only when the embedded app runtime
/// in Ghostty says so (usually, only in a reload configuration callback). /// in Ghostty says so (usually, only in a reload configuration callback).
var config: ghostty_config_t? = nil { @Published var config: ghostty_config_t? = nil {
didSet { didSet {
// Free the old value whenever we change // Free the old value whenever we change
guard let old = oldValue else { return } guard let old = oldValue else { return }
@ -33,7 +33,7 @@ extension Ghostty {
/// The ghostty app instance. We only have one of these for the entire app, although I guess /// The ghostty app instance. We only have one of these for the entire app, although I guess
/// in theory you can have multiple... I don't know why you would... /// in theory you can have multiple... I don't know why you would...
var app: ghostty_app_t? = nil { @Published var app: ghostty_app_t? = nil {
didSet { didSet {
guard let old = oldValue else { return } guard let old = oldValue else { return }
ghostty_app_free(old) ghostty_app_free(old)