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

Handle components on unsupported hosts. #182

Merged
merged 73 commits into from
Dec 23, 2022

Conversation

Exairnous
Copy link
Contributor

@Exairnous Exairnous commented Dec 11, 2022

Depends on #145
Displays a warning message about unsupported hosts in the migration report.
Adds a simple ui for the component with a warning and a remove button, the same as unknown components do.
Improves host checking for warning messages and deduplicates this.
Removes the unused OBJECT_DATA member from the PanelType Enum.

The relevant commits for this PR are the last five listed.

Redirect the output of sys.stdout for bpy.context.window_manager.print_undo_steps()
to allow for checking for append/link operations on a depsgraph update.
Modify the migration handler to support local migrations and check whether
the gizmo system needs to be activated.  Refactor migrations to be performed
on individual components so they're simpler and more performant.
Compare the raw string of undo steps rather than the built list for early exit.
(This should be more performant)

Add a comment clarifying why the handler returns early if the undo stack hasn't
changed.

Rename undo_steps_archive to be consistent in style with previous_undo_step_index
and move them to the bottom of the handler.
…rer/more stable.

Because Windows enables buffering on the C stdout flushing is necessary
to retrieve the data (and it's probably good to flush beforehand to make
sure only the requested data is retrieved).  Also, simplify reading from
the pipe and make things more fault tolerant/clean up some missed things.
Hopefully prevent any truncation of pointers to 32 bits on 64 bit systems.
Change Windows code to first try to flush the C stdout only, but fall back to flushing all output streams.
Fix the C stdout not being found on Mac.
Fall back to not flushing on Linux/Mac if the C stdout can't be found.
Improve comments.
…prove comments.

It looks like undo stores a snapshot of data for each step, so undo steps
after the initial append contain the migrated data, but because the migration
doesn't change the initial append undo step, you see the unmigrated data when
returning to it.
Add the add-on version to each component when it's created.
Refactor get_version_string function and move it from gltf_exporter
to the main utils file.
…nd return the get_version_string function to gltf_exporter.py
Blender sometimes triggers the depsgraph update handler when it's internal
state isn't fully loaded/usable, so detect if this is the case and return early.
…e open.

It turns out that space_data is invalid when more than one Blender window
is open, so add a check for if the file has just loaded.  Only skip the
handler if a file has just been loaded and space_data is invalid
(i.e. it will crash if the handler is run in this state).
Add functionality for migration methods to report messages.
Add migration report messages to audio_settings, audio_params,
loop_animation, and media_frame.
Enclose migration calls in a try/except block to prevent errors
from stopping the whole migration and report any errors encountered.
Add a popup viewer to display these messages.
Add a View Last Hubs Report operator to the "Window" menu.

This allows migrations to report messages individually to be displayed
in a popup viewer.  The viewer is generic and can be used in the future
to report other messages.  Users can save and view the report in the
Info editor, and the last report can be shown again via a menu item in
Blender's "Window" menu.  Migration reports are currently only shown for
local migrations, unless one or more components error out during migration.
…OBAL migration messages.

Allow migrations to send messages based on migration type.
Make the Loop Animation warning only trigger when invalid tracks are added for both GLOBAL and LOCAL migrations.
Report failed migrations for GLOBAL migrations in the regular migration report variable.
Clean up debug prints.
Add comments for all arguments passed to migrate in hubs_component.py
Reference components in the migration report title.
Add operator/button to view/save the report in the info editor to
the bottom of the report viewer and make the OK button just close.
Prevent widgets and objects from getting out of sync.
Fix the gizmo system not getting turned off completely when there aren't any gizmos.
Convert the append/link handler to a complete undo stack handler
and fix the gizmo system not re-initializing on undo/redo.
Add a task scheduler to the undo_stack_handler to allow performance heavy
tasks (currently only update_gizmos) to be combined and executed at the end
of the handler.
Add an option to not call update_gizmos directly in the migration function
and handle it outside.
Update the add/remove component functions to only update gizmos if they're
adding a gizmo component.
Force a depsgraph update at the end of the add/remove component operators
so that the undo_stack_handler will handle them immediately, rather than
delaying them to a future undo step which may be a suboptimal time for a
gizmo update.
Since the changes to improve performance[1], the object name msgbus
handlers have been redundant (and they also probably leaked memory
since they were introduced) because objects are stored directly
instead of being looked up by name in the refresh method.

[1] commit 2ee7839
…aph update.

The previous code only worked for objects and was a bit hacky, this works for
everything and is a more approved method.
Allow suppression of migration reports.  Reports are now basically
only triggered when objects are first linked/appended.
Allow use of the step type (DO/UNDO) in the undo_stack handler.
Add migrate components to the possible scheduled tasks.
Make sure linked objects remain migrated.
Update gizmos for various operators that can be used to add linked
objects and assets to the scene.
Warn about possible incorrect migrations for linked components on file load.
Add which linked components were migrated to the migration report.
Switch from storing the add-on version on the component instances to using individual component versions in the definitions and on each instance.
Clearly differentiate the names in the code for each type of version
(definition and instance).
Only attempt migrations if there is a version difference.
Remove the function to get the add-on version as it is no longer needed.
Fix bone components from previous betas missing getting versioned
if there were no components on the armature.
Move the check for a linked host to before looping through the components,
instead of checking whether the host is linked for each component.
Note: new lines are converted to two spaces for display in the info editor
to keep the messages as singular discrete sections.  More than one new line
together isn't allowed.
Include an abbreviated version of the error in the migration report
and print the full traceback to the console.
A header icon can be provided and will be shown at the beginning of the
first line of wrapped text.

Use the function to display report messages in the report viewer.
Numerical prefixes begin at one and are padded with a single leading zero.
This is applied to both the report viewer and the info editor.
Keep the report viewer window a consistent size and evenly pad the space
between messages, except when there are less than 4 messages in which case
all extra padding is added to the bottom and only a single line is used to
separate the messages.  If the messages can't be evenly spaced then
prioritize padding the bottom messages first.

15 lines are shown and a maximum of 5 messages.

Calculate/prepare the messages, and their padding, to be shown for each
starting index in advance when the report is first displayed and then
just display the messages that will fit in the window for the current
index.  If a message is larger than the allotted size, it will be the
only one displayed for that index and the window will stretch to
accommodate it.  Precalculating/preparing the messages keeps the whole
process fairly simple and is needed to accurately display the current
position in the report with the percentage bar since the number of
messages displayed for each index is now variable.

Improve variable names to prevent confusion.
The previous method for preventing internal HubsComponent base class
properties from sometimes being displayed in component subclasses didn't
preserve the order they were defined in and resulted in properties being
displayed differently each time in an unordered fashion.  This fixes it
so that the properties are displayed/gathered in the order they are defined.
Somehow the audio component test file got migrated to version
1.0.0 but the networked component never got saved into the file.
This caused the audio component test to fail because networked
components are no longer migrated on each file load, but are only
migrated once if the parent component requires it.  To fix this,
the audio component test file was recreated from scratch with the
latest release of the add-on (0.0.15) and the first supported
Blender LTS version (2.93.9)
This allows components to be migrated if the add-on is enabled after
a file with Hubs components has already been loaded.
This migration is only triggered when the add-on is activated in the
middle of a session.  An undo step is added to help prevent an
accidental loss of the migration, and a message is displayed to warn
the user if a migration actually occurs along with any local
migration messages.
Use the is_linked function for checking whether something is linked
during a migration/beta version update rather than checking everything
manually, and make the is_linked function always return a bool, rather
than sometimes returning the library or library override (this makes
the return type consistent and conform to what is expected.  It also
makes it compatible with logical bitwise operations).
Combine .utils imports in handlers.py.
Remove unused import from networked.py.
Convert the undo_stack_handler dummy keyword
argument back to a regular argument as it is
no longer needed.
Apply PEP 8 formatting with format.py.
Display a warning message on migration about components on unsupported hosts.
Display a simple panel for the component, similar to what is done for unknown
components, and allow the user to remove the components.

A method is provided to allow custom messages for components on unsupported hosts.
Add a utility function to retrieve the host reference for warning messages that is
less hacky than the current method.
Refactor the component poll methods to receive
the component host, and optionally the object,
as an argument and use them directly, rather than
receiving the context, which isn't correct during
migrations, and using that to get the host/object.

Remove the warning message in the video-texture-source
component ui for no camera being found in the object
hierarchy.
…ones.

Switch from attempting to get the object from the id_data to passing in
the object directly.  Using the id_data actually returned the armature,
in this case, rather than the object.
Copy link
Contributor

@keianhzo keianhzo left a comment

Choose a reason for hiding this comment

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

LGTM

@keianhzo keianhzo merged commit 52b51d2 into Hubs-Foundation:master Dec 23, 2022
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