Skip to content
Closed
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: 4 additions & 1 deletion Sources/OpenSwiftUICore/Graph/GraphHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ open class GraphHost: CustomReflectable {
package init() {
let graph = Graph(shared: GraphHost.sharedGraph)
let globalSubgraph = Subgraph(graph: graph)
let oldCurrentSubgraph = Subgraph.current
defer {
Subgraph.current = oldCurrentSubgraph
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It should not use defer as it should be set after addChild
  2. This is a change from 6.0.87 to 6.5.4. And this file is currently aligned with 6.0.87. I have noticed this and plan to upgrade the whole implementation later.

}
Subgraph.current = globalSubgraph
let time = Attribute(value: Time.zero)
let environment = Attribute(value: EnvironmentValues())
Expand All @@ -84,7 +88,6 @@ open class GraphHost: CustomReflectable {

let rootSubgrph = Subgraph(graph: graph)
globalSubgraph.addChild(rootSubgrph)
Subgraph.current = nil

self.graph = graph
self.globalSubgraph = globalSubgraph
Expand Down
5 changes: 4 additions & 1 deletion Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ package final class ViewGraph: GraphHost {
self.rootViewType = rootViewType
self.requestedOutputs = requestedOutputs
let data = GraphHost.Data()
let oldCurrentSubgraph = Subgraph.current
defer {
Subgraph.current = oldCurrentSubgraph
}
Subgraph.current = data.globalSubgraph
rootView = Attribute(type: Root.self).identifier
_rootTransform = Attribute(RootTransform())
Expand Down Expand Up @@ -188,7 +192,6 @@ package final class ViewGraph: GraphHost {
}
}
super.init(data: data)
Subgraph.current = nil
}

deinit {
Expand Down
Loading