Fix T58772: Stray "forward" and "up" options in 2.8 import addons?

Nice side-effect of using new __annotations__ thingy to store
dynamically-generated fields in a class: __annotations__ dict is not
ensured to exist for a given class, so we may end up modifying on of the
parents' one!
This commit is contained in:
Bastien Montagne 2018-12-05 10:57:08 +01:00
parent 80ffd7b459
commit 74361eebe6
Notes: blender-bot 2023-04-14 09:18:04 +02:00
Referenced by commit 5ad217fe0a, Fix own mistake in recent rB74361eebe68c.
Referenced by issue blender/blender-addons#58772, Stray "forward" and "up" options in 2.8 import addons?
1 changed files with 5 additions and 0 deletions

View File

@ -127,6 +127,11 @@ def orientation_helper(axis_forward='Y', axis_up='Z'):
with specified default values (axes).
"""
def wrapper(cls):
# Without that, we may end up adding those fields to some **parent** class' __annotations__ property
# (like the ImportHelper or ExportHelper ones)! See T58772.
if "__annotations__" not in cls.__dict__:
cls.__dict__["__annotations__"] = {}
def _update_axis_forward(self, context):
if self.axis_forward[-1] == self.axis_up[-1]:
self.axis_up = (self.axis_up[0:-1] +