Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Replace event monitor with native SwiftUI .onKeyPress() in connection switcher
- Extract reusable SearchFieldView component from 4 custom search field implementations
- Replace timing hacks with structured signals (polling loops, arbitrary delays)
- Fix potential hang when coordinator deallocates during save (saveCompletionContinuation)
- Fix potential hang when multiple subsystems await WindowOpener readiness simultaneously

### Changed

Expand Down
10 changes: 6 additions & 4 deletions TablePro/Core/Services/Infrastructure/WindowOpener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ internal final class WindowOpener {

internal static let shared = WindowOpener()

private var readyContinuation: CheckedContinuation<Void, Never>?
private var readyContinuations: [CheckedContinuation<Void, Never>] = []

/// Set on appear by ContentView, WelcomeViewModel, or ConnectionFormView.
/// Safe to store — OpenWindowAction is app-scoped, not view-scoped.
internal var openWindow: OpenWindowAction? {
didSet {
if openWindow != nil {
readyContinuation?.resume()
readyContinuation = nil
for continuation in readyContinuations {
continuation.resume()
}
readyContinuations.removeAll()
}
}
}
Expand All @@ -35,7 +37,7 @@ internal final class WindowOpener {
if openWindow != nil {
continuation.resume()
} else {
readyContinuation = continuation
readyContinuations.append(continuation)
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions TablePro/Views/Main/MainContentCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ final class MainContentCoordinator {
}

deinit {
saveCompletionContinuation?.resume(returning: false)
saveCompletionContinuation = nil

let connectionId = connection.id
let alreadyHandled = _didTeardown.withLock { $0 } || _teardownScheduled.withLock { $0 }

Expand Down
Loading