Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix potential hang when coordinator deallocates during save
- Fix Cmd+W save not persisting data grid changes (sidebar edits intercepted save path)

## [0.27.5] - 2026-04-06

### Added
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
33 changes: 30 additions & 3 deletions TablePro/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -5964,6 +5964,9 @@
}
}
}
},
"Change Primary Key" : {

},
"Character Set" : {
"localizations" : {
Expand Down Expand Up @@ -10610,7 +10613,6 @@
}
},
"Delete Column" : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand Down Expand Up @@ -10699,7 +10701,6 @@
}
},
"Delete Foreign Key" : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand Down Expand Up @@ -10744,7 +10745,6 @@
}
},
"Delete Index" : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand Down Expand Up @@ -10815,6 +10815,12 @@
}
}
}
},
"Delete Row" : {

},
"Delete Rows" : {

},
"Delete Selected" : {
"localizations" : {
Expand Down Expand Up @@ -11689,6 +11695,12 @@
}
}
}
},
"Edit Cell" : {

},
"Edit Column" : {

},
"Edit Connection" : {
"localizations" : {
Expand Down Expand Up @@ -11734,6 +11746,12 @@
}
}
}
},
"Edit Foreign Key" : {

},
"Edit Index" : {

},
"Edit Profile..." : {
"localizations" : {
Expand Down Expand Up @@ -17115,6 +17133,12 @@
}
}
}
},
"Insert Row" : {

},
"Insert Rows" : {

},
"INSERT Statement(s)" : {
"localizations" : {
Expand Down Expand Up @@ -28525,6 +28549,7 @@
}
},
"Search for field..." : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand Down Expand Up @@ -28636,6 +28661,7 @@
}
},
"Search shortcuts..." : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand All @@ -28658,6 +28684,7 @@
}
},
"Search tables, views, databases..." : {
"extractionState" : "stale",
"localizations" : {
"tr" : {
"stringUnit" : {
Expand Down
30 changes: 22 additions & 8 deletions TablePro/Views/Main/MainContentCommandActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,36 @@ final class MainContentCommandActions {
return
}

// Sidebar edits
// Data grid changes or pending table operations take priority
let hasDataChanges = coordinator.changeManager.hasChanges
|| !pendingTruncates.wrappedValue.isEmpty
|| !pendingDeletes.wrappedValue.isEmpty
if hasDataChanges {
let saved = await withCheckedContinuation { continuation in
coordinator.saveCompletionContinuation = continuation
saveChanges()
}
if saved {
performClose()
}
return
}

// Sidebar-only edits (made directly in the inspector panel)
if rightPanelState.editState.hasEdits {
rightPanelState.onSave?()
performClose()
return
}

// Data grid changes: await the async save via continuation
let saved = await withCheckedContinuation { continuation in
coordinator.saveCompletionContinuation = continuation
saveChanges()
}

if saved {
// File save (query editor with source file)
if coordinator.tabManager.selectedTab?.isFileDirty == true {
saveFileToSourceURL()
performClose()
return
}

performClose()
}

private func saveFileToSourceURL() {
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