Commit 0334b5b
committed
Fixes for runtime model mutation violations
Fixing runtime errors like:
ActionUI/ActionUI/Common/ActionUIModel.swift:79 Publishing changes from within view updates is not allowed, this will cause undefined behavior.
Fix 1 — WindowModalView.swift: Changed dialog binding setters to use ActionUIModel.shared.dismissDialog(windowUUID:) instead of directly mutating windowModel.windowDialog. This prevents state mutation during the SwiftUI render cycle when dismissing alerts/confirmation dialogs.
Fix 2 — WindowModel.swift: Removed @published from element and viewModels.
- WindowModalView is the only @ObservedObject observer of WindowModel. It only needs to react to windowModal and windowDialog changes (to show/hide presentation modifiers). Those remain @published.
- element and viewModels are only read as direct lookups — by FileLoadableView.body, WindowGroup, FileLoadableWindowGroupHelper, etc. — none of which use @ObservedObject observation on WindowModel. They read the current value at render time.
- Individual ViewModel instances have their own ObservableObject for per-view reactivity (via objectWillChange.send() in setElementValue, setElementState, setElementProperty, etc.), so @published on the dictionary was redundant for runtime updates.
- All load methods remain synchronous — no deferred DispatchQueue.main.async, so viewModels are immediately available when FileLoadableView.body executes, and tests work without changes.1 parent 5597a10 commit 0334b5b
2 files changed
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
0 commit comments