forked from 1b-agent/opencadstudio-upstream
XCLIP: a copy taken before the clip was set still finds its filter
insert_spatial_filter reads the INSERT's own dictionary link since 3a3d2e4a8; a caller holding a copy made before XCLIP linked the dictionary saw none. Fall back to the stored INSERT's link, still O(1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4158fda45c
commit
76afd7eabb
1 file changed
+16
-8
+16
-8
@@ -48,12 +48,20 @@ fn resolve_extension_dictionary(doc: &CadDocument, owner: Handle) -> Option<Hand
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The INSERT's extension dictionary through its own link. Render walks ask
|
/// The INSERT's extension dictionary through its own link, or the stored
|
||||||
/// this for every INSERT, so it must not fall back to a scan of every object:
|
/// INSERT's when `ins` is a copy taken before the link was made. Render walks
|
||||||
/// [`CadDocument::extension_dictionary_handle`] scans for an entity without
|
/// ask this for every INSERT, so it must not fall back to a scan of every
|
||||||
/// a linked dictionary. Readers and `ensure_extension_dictionary` set the link.
|
/// object: [`CadDocument::extension_dictionary_handle`] scans for an entity
|
||||||
fn linked_extension_dictionary(ins: &Insert) -> Option<Handle> {
|
/// without a linked dictionary. Readers and `ensure_extension_dictionary`
|
||||||
ins.common.xdictionary_handle.filter(|h| !h.is_null())
|
/// set the link.
|
||||||
|
fn linked_extension_dictionary(doc: &CadDocument, ins: &Insert) -> Option<Handle> {
|
||||||
|
ins.common
|
||||||
|
.xdictionary_handle
|
||||||
|
.or_else(|| {
|
||||||
|
doc.get_entity(ins.common.handle)
|
||||||
|
.and_then(|stored| stored.common().xdictionary_handle)
|
||||||
|
})
|
||||||
|
.filter(|h| !h.is_null())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve the enabled XCLIP spatial filter for `ins`, if any.
|
/// Resolve the enabled XCLIP spatial filter for `ins`, if any.
|
||||||
@@ -63,7 +71,7 @@ fn linked_extension_dictionary(ins: &Insert) -> Option<Handle> {
|
|||||||
/// filter, it is disabled (code 71 = 0), or it has fewer than two boundary
|
/// filter, it is disabled (code 71 = 0), or it has fewer than two boundary
|
||||||
/// points.
|
/// points.
|
||||||
pub fn insert_spatial_filter<'a>(doc: &'a CadDocument, ins: &Insert) -> Option<&'a SpatialFilter> {
|
pub fn insert_spatial_filter<'a>(doc: &'a CadDocument, ins: &Insert) -> Option<&'a SpatialFilter> {
|
||||||
let xdict = linked_extension_dictionary(ins)?;
|
let xdict = linked_extension_dictionary(doc, ins)?;
|
||||||
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
||||||
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
||||||
match doc.objects.get(&spatial)? {
|
match doc.objects.get(&spatial)? {
|
||||||
@@ -81,7 +89,7 @@ pub fn filter_handle(doc: &CadDocument, insert: Handle) -> Option<Handle> {
|
|||||||
let Some(codec::EntityType::Insert(ins)) = doc.get_entity(insert) else {
|
let Some(codec::EntityType::Insert(ins)) = doc.get_entity(insert) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let xdict = linked_extension_dictionary(ins)?;
|
let xdict = linked_extension_dictionary(doc, ins)?;
|
||||||
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
||||||
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
||||||
matches!(
|
matches!(
|
||||||
|
|||||||
Reference in new issue
Block a user