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

View File

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