forked from 1b-agent/opencadstudio-upstream
fix(io): resolve root named-objects dict robustly on foreign DWGs
Some DWGs written by other programs leave the root named-objects dictionary unrecoverable: the header pointer names a non-dictionary and the real NOD child dicts are owned by a table-control handle, so nothing has owner==NULL. Navigating the root then silently no-ops, and registering a new named-object entry (page setup, annotation scale, CTAB) against the missing root orphans it — it never round-trips. Add shared annotative::root_named_dict_handle(): resolve the header pointer, else adopt the richest owner==NULL dict, else synthesise a fresh root and write it back. Route ensure_plotsettings_dict, add_scale's scalelist-create branch, and set_saved_active_layout through it. Resolve the plot-settings dict via the PlotSettings owner when the header pointer is stale, mirroring scalelist_dict_handle. Verified page setups survive a DWG save/reload on the repro file with layouts intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c4272fbb0
commit
04bd49c715
5 files changed
+227
-32
No files matched your search
+5
-1
@@ -1967,7 +1967,11 @@ impl Scene {
|
||||
let scalelist_h = match self.scalelist_dict_handle() {
|
||||
Some(h) => h,
|
||||
None => {
|
||||
let root_h = self.document.header.named_objects_dict_handle;
|
||||
// Resolve (or synthesise) the root robustly — a drawing whose
|
||||
// header root pointer is unresolvable would otherwise register
|
||||
// the new dictionary against a missing root and silently orphan
|
||||
// it. See `annotative::root_named_dict_handle`.
|
||||
let root_h = crate::scene::annotative::root_named_dict_handle(&mut self.document);
|
||||
let h = self.document.allocate_handle();
|
||||
let mut d = Dictionary::new();
|
||||
d.handle = h;
|
||||
|
||||
Reference in new issue
Block a user