Skip to content

Commit f1bf4f9

Browse files
committed
[Fixed] What we copy for repeated components
When the user provides an NxM panel we get N*M copies of the components. We need them to allow filters and stats to differentiate them. But we don't need to deepcopy all the references, in particular: - Parent sheet - Project instance map - Library symbol drawing Fixes #842
1 parent b12233b commit f1bf4f9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

kibot/kicad/v6_sch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,20 @@ def set_footprint(self, fp):
11341134
raise SchError('Footprint with more than one colon (`{}`)'.format(fp))
11351135
self.set_field('Footprint', fp)
11361136

1137+
def copy(self):
1138+
""" Make a deep copy, but not for all """
1139+
# Don't copy the links to projects, parent_sheet and library symbol
1140+
projects = self.projects
1141+
parent_sheet = self.parent_sheet
1142+
lib_symbol = self.lib_symbol
1143+
self.projects = self.parent_sheet = self.lib_symbol = None
1144+
# All the rest is copied
1145+
new_c = deepcopy(self)
1146+
new_c.projects = self.projects = projects
1147+
new_c.parent_sheet = self.parent_sheet = parent_sheet
1148+
new_c.lib_symbol = self.lib_symbol = lib_symbol
1149+
return new_c
1150+
11371151
@staticmethod
11381152
def get_lib_and_name(comp, i, name):
11391153
comp.lib_id = comp.name = _check_str(i, 1, name+' lib_id')

kibot/kiplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def get_board_comps_data(comps):
424424
comps.append(c)
425425
if c.has_pcb_info:
426426
# We already got this reference and filled the PCB info, this is another copy
427-
c = deepcopy(c)
427+
c = c.copy()
428428
comps.append(c)
429429
new_value = m.GetValue()
430430
if new_value != c.value and '${' not in c.value:

0 commit comments

Comments
 (0)