Skip to content

Crash on bad MHMAT link #420

Description

@joepal1976

It's an edge case, but in case you installed a corrupt asset where the MHCLO points at a non-existing MHMAT, you get an ugly crash:

[CRASH] ui.new_human.randomize.createrandomhuman : Execution caused an exception 

An unhandled error was encountered. Please provide this info in an error report:

CONTEXT
-------
context .............. : <bpy_struct, Context at 0x7d35ade865c8>
scene ................ : <bpy_struct, Scene("Scene") at 0x7d332acf00a0>
active_object ........ : <bpy_struct, Object("Human.sssnake_starship_uniform_green_capt_shirt") at 0x7d353f165608>
active_object_mode ... : OBJECT
active_object_type ... : Clothes

OPERATOR
--------
name ................. : MPFB_OT_create_random_human
label...... .......... : Create random human

SYSTEM
------
blender_version ...... : (5, 1, 0)
blender_version_string : 5.1.0
python_version ....... : 3.13.9 (main, Apr 25 2025, 12:39:20) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)]
platform ............. : Linux-6.8.0-136-generic-x86_64-with-glibc2.39
platform system....... : Linux
platform release...... : 6.8.0-136-generic

MPFB
----
version .............. : (2, 0, 17)
build ................ : FROM_SOURCE
data dir ............. : /home/joepal/raspberry/mpfb2/src/mpfb/data
mpfb dir ............. : /home/joepal/raspberry/mpfb2/src/mpfb
user dir ............. : /home/joepal/makehuman/mpfb

ERROR
-----
type ................. : FileNotFoundError
message .............. : [Errno 2] No such file or directory: '/home/joepal/makehuman/mpfb/data/clothes/sssnake_starship_uniform_green_capt_shirt/starship_uniform.mhmat'

STACK TRACE
-----------
Traceback (most recent call last):
  File "/home/joepal/source/blender-extensions/repo/mpfb/ui/mpfboperator.py", line 110, in execute
    return self.hardened_execute(context)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/joepal/source/blender-extensions/repo/mpfb/ui/new_human/randomize/operators/createrandomhuman.py", line 50, in hardened_execute
    basemesh = characterbuilder.build_character(spec, macro_details, rng, self.report, discovery)
  File "/home/joepal/source/blender-extensions/repo/mpfb/ui/new_human/randomize/characterbuilder.py", line 163, in build_character
    _apply_random_clothes(report, spec, macro_details, basemesh, rng, discovery, subdiv_levels)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joepal/source/blender-extensions/repo/mpfb/ui/new_human/randomize/characterbuilder.py", line 400, in _apply_random_clothes
    HumanService.add_mhclo_asset(pick["path"], basemesh, asset_type="Clothes", subdiv_levels=subdiv_levels,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                 material_type=material_type)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joepal/source/blender-extensions/repo/mpfb/services/humanservice.py", line 565, in add_mhclo_asset
    makeskin_material.populate_from_mhmat(material)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/joepal/source/blender-extensions/repo/mpfb/entities/material/mhmaterial.py", line 79, in populate_from_mhmat
    with open(full_path, 'r') as f:
         ~~~~^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/joepal/makehuman/mpfb/data/clothes/sssnake_starship_uniform_green_capt_shirt/starship_uniform.mhmat'

Desired outcome is that there instead is an informative warning that the material could not be loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions