Skip to content

Commit 7d80f9f

Browse files
Richardn2002paroj
authored andcommitted
Fix _OgreCommonExport_.converter not initialized on Blender 4.4.
Blender 4.4 release notes say nothing about addon API change, but I am experiencing ``` Traceback (most recent call last): File "/home/richardn/.config/blender/4.4/scripts/addons/io_ogre/ui/export.py", line 78, in draw if self.converter == "unknown": ^^^^^^^^^^^^^^ File "/usr/share/blender/4.4/scripts/modules/bpy_types.py", line 940, in __getattribute__ return super().__getattribute__(attr) ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ AttributeError: 'OP_ogre_export' object has no attribute 'converter' ``` after upgrading to 4.4 (Error triggered when opening the export dialog, and due to the error no export settings widget will be shown, and export will fail dramatically). After some investigation I am still confused why old code broke (instantiation should have happened before `.draw()` is called?), but what I changed here respects what is written in Blender API docs, and fixes the problem I bumped into.
1 parent 8080877 commit 7d80f9f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

io_ogre/ui/export.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ def menu_func(self, context):
3535
class _OgreCommonExport_(object):
3636

3737
called_from_UI = False
38+
converter = "unknown"
3839

3940
@classmethod
4041
def poll(cls, context):
4142
if context.active_object and context.mode != 'EDIT_MESH':
4243
return True
4344

44-
def __init__(self):
45-
# Check that converter is setup
46-
self.converter = detect_converter_type()
45+
# https://docs.blender.org/api/current/bpy.utils.html#bpy.utils.register_class
46+
# > If the class has a register class method it will be called before registration.
47+
# call chain: __init__.py::register() -> bpy.utils.register_class() -> (Blender internals) -> Self::register()
48+
@classmethod
49+
def register(cls):
50+
cls.converter = detect_converter_type()
4751

4852
def invoke(self, context, event):
4953
# Update the interface with the config values

0 commit comments

Comments
 (0)