Skip to content

Commit da9a5ef

Browse files
committed
Fix addHostValue’s missing graphInvalidation call
1 parent 664fbac commit da9a5ef

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/OpenSwiftUI/Data/Preference/PreferenceBridge.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ final class PreferenceBridge {
9292
) { combiner in
9393
combiner.addChild(keys: keys, values: values)
9494
}
95+
viewGraph.graphInvalidation(from: combiner.identifier)
9596
}
9697

9798
func removeHostValue(for keys: Attribute<PreferenceKeys>, isInvalidating: Bool) {

Sources/OpenSwiftUI/Data/Preference/PreferencesCombiner.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ struct HostPreferencesCombiner: Rule, AsyncAttribute {
4040
struct Child {
4141
@WeakAttribute var keys: PreferenceKeys?
4242
@WeakAttribute var values: PreferenceList?
43+
44+
init(keys: Attribute<PreferenceKeys>, values: Attribute<PreferenceList>) {
45+
_keys = WeakAttribute(keys)
46+
_values = WeakAttribute(values)
47+
}
4348
}
4449

4550
#if canImport(Darwin) // FIXME: See #39
4651
mutating func addChild(keys: Attribute<PreferenceKeys>, values: Attribute<PreferenceList>) {
47-
let weakKeys = OGWeakAttribute(keys.identifier)
48-
let weakValues = OGWeakAttribute(values.identifier)
49-
let child = Child(keys: .init(base: weakKeys), values: .init(base: weakValues))
52+
let child = Child(keys: keys, values: values)
5053
if let index = children.firstIndex(where: { $0.$keys == keys }) {
5154
children[index] = child
5255
} else {

0 commit comments

Comments
 (0)