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

General: Attribute definitions fixes #4392

Merged
merged 19 commits into from
Feb 1, 2023
Merged

Conversation

iLLiCiTiT
Copy link
Member

@iLLiCiTiT iLLiCiTiT commented Jan 27, 2023

Brief description

Fix possible issues with attribute definitions in publisher if there is unknown attribute on an instance.

Description

Source of the issue is that attribute definitions from creator plugin could be "expanded" during CreatedInstance initialization. Which would affect all other instances using the same list of attributes -> literally object of list. If the same list object is used in "BaseClass" for other creators it would affect all instances (because of 1 instance). There had to be implemented other changes to fix the issue and keep behavior the same.

Object of CreatedInstance can be created without reference to creator object. CreatedInstance is responsible to give UI attribute definitions (technically is prepared for cases when each instance may have different attribute definitions -> not yet).
Attribute definition has added more conditions for __eq__ method and have implemented __ne__ method (which is required for Py 2 compatibility). Renamed AbtractAttrDef to AbstractAttrDef (fix typo).

Developer explanation of bug

Imagine there are 2 instances in the scene created by same creator. One would have in attribute "key1" in creator attributes, second would have attribute "key2" in creator attributes but creator would return empty list for attribute definitions one. After collection both instances would have both attributes shown in UI and saved to scene because both added UnknownDef to creator's attribute definitions.

In case the creator would inherit from class which return the list of attributes from attribute and there were more creators like that then all "unknown" attributes would get to all instances collected by those creators (fun with python pointers).

Additional information

Currently multiselection of instances may cause that attributes are not loaded as fast (that because of very inefficient way how to find "common attributes" for all instances. That could be solved by implementing "create hash" method for attribute definitions. The result would be string which would contain all information which makes the attribute unique by combination of all definitions properties (could be huge for enums). We could look into that if we'll find out it's an issue.

# Example of attribute definition
NumberDef(
    "my_num",
    minimum=1.0,
    maximum=20.0,
    decimals=1,
    default=5.0,
    hidden=False,
    disabled=False
)

# Simplified possible tempalte for number definition
hast_str_template = "{class}|{key}|{hidde}|{disabled}|{default}|{minimum}|{maximum}|{decimals}"

# The result for the object above
hash_str = "NumberDef|my_num|0|0|5.0|1.0|20.0|1"

Testing notes:

Hosts where is used New Publisher should work as before (or better).

  1. Open one of the hosts e.g. TrayPublisher
  2. Open publisher UI
  3. Create part should show precreate attributes as expected
  4. Create few instances
  5. Instance attributes in Publish category should be shown correctly and they should work on multiselection

More complex testing:
Follow steps in this issue #4379

Resolves #4379

@mkolar mkolar added the type: bug Something isn't working label Jan 30, 2023
Copy link
Member

@kalisp kalisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in Publisher, Nuke, AE, didn't notice irregularities from before.

(But I didn't have mentioned issues that this should fix.)

@iLLiCiTiT iLLiCiTiT merged commit 6fb280b into develop Feb 1, 2023
@iLLiCiTiT iLLiCiTiT deleted the bugfix/instance_attr_defs_fix branch February 1, 2023 14:56
@github-actions github-actions bot added this to the next-patch milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Houdini: New Publisher doesn't refresh attributes correctly
3 participants