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

Check for active object before switching to object mode #74

Merged
merged 1 commit into from
Dec 21, 2021

Conversation

TapGhoul
Copy link

@TapGhoul TapGhoul commented Dec 21, 2021

When the exporter iterates through each mesh to export, it needs to enter edit mode to work with the mesh data.
Before this must happen, we must enter object mode so we can pick the mesh we want to use.

However, in some cases, there will be no mesh selected - causing mode_set() to fail, as there is no active object, causing a crash.
This fixes this crash by just not bothering to switch into object mode if nothing is selected, as it's a redundant operation at that point.

Additionally, blender safeguards against misbehavior here - if you try to deselect bpy.context.view_layer.objects.active by setting it to none while in any mode other than object mode, it kicks you back into object mode, allowing you to select a new mesh.

Fixes #70

@TapGhoul TapGhoul marked this pull request as ready for review December 21, 2021 07:54
@saturday06 saturday06 force-pushed the next branch 3 times, most recently from b74dd7e to 36fb2c2 Compare December 21, 2021 12:07
@saturday06
Copy link
Owner

Thank you very much !

@saturday06 saturday06 merged commit 2e1237a into saturday06:next Dec 21, 2021
@TapGhoul TapGhoul deleted the issue-70 branch December 21, 2021 19:13
saturday06 added a commit that referenced this pull request Dec 28, 2021
Restore #74 that was incorrectly removed by f0c397b
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