Solved an ownership issue in DRC which popped up after universal DRC nodes got deleted.

This commit is contained in:
Matthias Koefferlein 2022-11-23 00:36:08 +01:00
parent 86cc523c77
commit 7431ec6f43
2 changed files with 14 additions and 12 deletions

View File

@ -232,15 +232,15 @@ class DRCOpNode
attr_accessor :description attr_accessor :description
attr_accessor :engine attr_accessor :engine
def initialize(engine, node = nil) def initialize(engine, &factory)
@node = node @factory = factory
self.engine = engine self.engine = engine
self.description = "Basic" self.description = "Basic"
end end
def create_node(cache) def create_node(cache)
n = cache[self.object_id] n = cache[self.object_id]
if !n if !n || n.destroyed?
n = self.do_create_node(cache) n = self.do_create_node(cache)
cache[self.object_id] = n cache[self.object_id] = n
end end
@ -248,7 +248,7 @@ class DRCOpNode
end end
def do_create_node(cache) def do_create_node(cache)
@node @factory.call
end end
def dump(indent) def dump(indent)
@ -362,8 +362,8 @@ CODE
return self.inverted return self.inverted
else else
# TODO: what if the expression isn't region? # TODO: what if the expression isn't region?
empty = RBA::CompoundRegionOperationNode::new_empty(RBA::CompoundRegionOperationNode::ResultType::Region) empty = DRCOpNode::new(@engine) { RBA::CompoundRegionOperationNode::new_empty(RBA::CompoundRegionOperationNode::ResultType::Region) }
DRCOpNodeCase::new(@engine, [ self, DRCOpNode::new(@engine, empty), @engine.primary ]) DRCOpNodeCase::new(@engine, [ self, empty, @engine.primary ])
end end
end end
end end

View File

@ -476,7 +476,7 @@ module DRC
layer.requires_region layer.requires_region
res = DRCOpNode::new(self, RBA::CompoundRegionOperationNode::new_secondary(layer.data)) res = DRCOpNode::new(self) { RBA::CompoundRegionOperationNode::new_secondary(layer.data) }
res.description = "secondary" res.description = "secondary"
return res return res
@ -493,7 +493,7 @@ module DRC
# is called on. # is called on.
def primary def primary
res = DRCOpNode::new(self, RBA::CompoundRegionOperationNode::new_primary) res = DRCOpNode::new(self) { RBA::CompoundRegionOperationNode::new_primary }
res.description = "primary" res.description = "primary"
return res return res
end end
@ -520,7 +520,7 @@ module DRC
# @/code # @/code
def foreign def foreign
res = DRCOpNode::new(self, RBA::CompoundRegionOperationNode::new_foreign) res = DRCOpNode::new(self) { RBA::CompoundRegionOperationNode::new_foreign }
res.description = "foreign" res.description = "foreign"
return res return res
end end
@ -1555,10 +1555,12 @@ CODE
def _make_node(arg) def _make_node(arg)
if arg.is_a?(DRCLayer) if arg.is_a?(DRCLayer)
arg = DRCOpNode::new(self, RBA::CompoundRegionOperationNode::new_secondary(arg.data)) node = DRCOpNode::new(self) { RBA::CompoundRegionOperationNode::new_secondary(arg.data) }
arg.description = "secondary" node.description = "secondary"
return node
else
return arg
end end
arg
end end
end end