fix(styles): follow text rename into dimstyle dimtxsty

rename_style_storage and rename_symbol rewrote entities and table rows but left dimtxsty stale, so the next Apply resolved a NULL handle. The follow now lives in both shared functions; the plugin workaround is removed as redundant. Tests: text_rename_follows_dimtxsty drives the manager path (RED first); pre-existing plugin rename test stays green via the shared path. Full suite: 2015 passed / 0 failed / 25 ignored.
This commit is contained in:
Karim Jerbi committed 2026-10-09 20:44:53 +01:00
1 parent 713930de82
commit a3742e5668
3 files changed
+43 -8

No files matched your search

+35
View File
@@ -610,6 +610,13 @@ impl OpenCADStudio {
}
}
}
// Dimension styles name their text style; follow the rename so
// Apply keeps resolving the handle instead of collapsing to NULL.
for ds in doc.dim_styles.iter_mut() {
if ds.dimtxsty.eq_ignore_ascii_case(old) {
ds.dimtxsty = new.to_string();
}
}
}
StyleKind::Dim => {
let doc = &mut self.tabs[i].scene.document;
@@ -1270,3 +1277,31 @@ impl OpenCADStudio {
}
}
}
#[cfg(test)]
mod rename_follow_tests {
// #42: renaming a text style must follow into dimstyle dimtxsty.
use super::{OpenCADStudio, StyleKind};
use codec::tables::{DimStyle, TextStyle};
#[test]
fn text_rename_follows_dimtxsty() {
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
let i = app.active_tab;
let mut ts = TextStyle::new("OLD");
ts.handle = app.tabs[i].scene.document.allocate_handle();
app.tabs[i].scene.document.text_styles.add(ts).unwrap();
let mut ds = DimStyle::new("D");
ds.dimtxsty = "OLD".to_string();
app.tabs[i].scene.document.dim_styles.add(ds).unwrap();
app.style_rename = Some("OLD".to_string());
app.style_rename_buf = "NEW".to_string();
app.style_rename_commit(StyleKind::Text);
let dim = app.tabs[i].scene.document.dim_styles.get("D").unwrap();
assert_eq!(
dim.dimtxsty, "NEW",
"dimstyle must follow the text-style rename"
);
}
}