Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing tif.get_type_name() on struct/enum change #122

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

themaks
Copy link
Contributor

@themaks themaks commented Oct 2, 2024

This fixes a problem in hooks.local_types_changed.

is_typedef, name, type_name = compat.typedef_info(tif, use_new_check=True)
new_type_type = None
if is_typedef:
self.interface.typedef_changed(Typedef(name=name, type_=type_name))
new_type_type = Typedef
elif tif.is_struct():
bs_struct = compat.bs_struct_from_tif(tif)
self.interface.struct_changed(bs_struct)
new_type_type = Struct
elif tif.is_enum():
bs_enum = compat.enum_from_tif(tif)
self.interface.enum_changed(bs_enum)
new_type_type = Enum
self.interface.cached_ord_to_type_names[ordinal] = (name, new_type_type)
return 0

When a struct or enum is modified, compat.typedef_info returns (False, None, None), so name is set to None.
Later, the type cache is updated using name=None (self.interface.cached_ord_to_type_names[ordinal] = (name, new_type_type)), causing major errors later on in the same function:

# was the type renamed?
if ordinal in self.interface.cached_ord_to_type_names:
old_name, _ = self.interface.cached_ord_to_type_names[ordinal]
if old_name != name:
self.bs_type_deleted(ordinal)

@mahaloz mahaloz merged commit a424150 into binsync:main Oct 3, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants