From 900f6d7b0faefa9899d5a72c4667a101416c7437 Mon Sep 17 00:00:00 2001 From: Ahmed Nematallah Date: Sun, 3 May 2026 05:12:21 +0200 Subject: [PATCH] Ensure all cells are loaded into memory in netlist_to_spice to avoid file corruption during save Added logic to ensure all cells are loaded into memory to prevent corruption when saving files. This is a fix for a minor edge case when generating "netlist_to_spice" for a file that already has a netlist, and which contains cells containing other cells. Followed by "writeall force". This causes unloaded files (that are still referenced) to be loaded during save with "ignoreTech" being true, and thus disregarding the scale, corrupting all coordinates if a scale is used. This was caused by skipping regenerating cells that already had a .mag file --- tcltk/toolkit.tcl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcltk/toolkit.tcl b/tcltk/toolkit.tcl index 346f93aa..77442a3f 100644 --- a/tcltk/toolkit.tcl +++ b/tcltk/toolkit.tcl @@ -536,6 +536,12 @@ proc magic::netlist_to_layout {netfile library} { if {[catch {load $subckt -fail -silent}] == 0} { puts stdout "Subcircuit $subckt successfully loaded." set existing_cells($subckt) "true" + + # Make sure to load all cells into memory to avoid + # corruption when saving all files (files get loaded + # without taking the scale into account) + select top cell + expand } else { puts stdout "Subcircuit $subckt not found. Will generate." set existing_cells($subckt) "false"