fix next_entity() and prev_entity() methods in command "browse"
PySide6 requires the casting call Tags(entity) in entity_activated(),
which prevents finding the entity by the "is" operator.
Solutions is comparing the first DXF tag by "is" operator.
@@ -124,17 +124,23 @@ class HandleIndex:
def next_entity(self, entity: Tags) -> Tags:
return_next = False
+ if len(entity):
+ # comparing Tags() is not safe!
+ first_tag = entity[0]
for e in self._index.values():
if return_next:
return e
- if e is entity:
+ if len(e) and e[0] is first_tag:
return_next = True
return entity
def previous_entity(self, entity: Tags) -> Tags:
prev = entity
+ if len(entity):
+ # comparing Tags() is not safe!
+ first_tag = entity[0]
for e in self._index.values():
- if e is entity:
+ if len(e) and e[0] is first_tag:
return prev
prev = e
return entity
