Skip to content

Commit

Permalink
Add some DIspatchQueues
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolwinter committed Jul 4, 2023
1 parent 44063ca commit d4e2943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ struct DebugAreaTerminalView: View {
url: terminal.url!,
shellType: terminal.shell,
onTitleChange: { newTitle in
handleTitleChange(id: terminal.id, title: newTitle)
// This can be called whenever, even in a view update so it needs to be dispatched.
DispatchQueue.main.async {
handleTitleChange(id: terminal.id, title: newTitle)
}
}
)
.padding(.top, 10)
Expand Down
5 changes: 4 additions & 1 deletion CodeEdit/Features/SplitView/SplitViewItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class SplitViewItem: ObservableObject {
self.item.canCollapse = child[SplitViewItemCanCollapseViewTraitKey.self]
self.item.isCollapsed = self.collapsed.wrappedValue
self.item.holdingPriority = child[SplitViewHoldingPriorityTraitKey.self]
self.observers = createObservers()
// Skip the initial observation via a dispatch to avoid a "updating during view update" error
DispatchQueue.main.async {
self.observers = self.createObservers()
}
}

private func createObservers() -> [NSKeyValueObservation] {
Expand Down

0 comments on commit d4e2943

Please sign in to comment.