Fixed KiCad project reload

- Otherwise KiCad SIGSEGVs when trying to plot
This commit is contained in:
Salvador E. Tropea 2022-12-03 20:48:49 -03:00
parent 4c356f14aa
commit f7dceabd0e
3 changed files with 6 additions and 4 deletions

View File

@ -432,6 +432,8 @@ class GS(object):
sm = pcbnew.GetSettingsManager()
sm.UnloadProject(GS.board.GetProject(), False)
assert sm.LoadProject(pro_name)
# If we use the old project KiCad SIGSEGV
GS.board = None
@staticmethod
def get_resource_path(name):

View File

@ -725,6 +725,9 @@ class PanelizeOptions(VariantOptions):
board = GS.load_board_low_level(name)
logger.debug('Creating preview image ...')
out.options.create_image(img_name, board)
# KiCad loads the project automagically, so now we have the wrong project loaded
# We need to unload the current project to load the new one
# But we also need to reload the PCB, this is ridiculous ...
GS.reload_project(GS.pro_file)
def run(self, output):

View File

@ -148,8 +148,5 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821
with open(pro_name, 'wt') as f:
f.write(json.dumps(data, sort_keys=True, indent=2))
if GS.board:
# Force a project reload
# Force a project and PCB reload
GS.reload_project(pro_name)
# TODO: Do we really need to reload the PCB?
# Force the PCB reload (will reload the project file)
GS.board = None