forked from blender/blender
Moved check of existing MaterialX addon from bpy_hydra.py to material.cc and log warning only once. #83
@ -121,17 +121,19 @@ void MaterialData::export_mtlx()
|
|||||||
|
|
||||||
if (!matx_addon_checked) {
|
if (!matx_addon_checked) {
|
||||||
gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
/* Adding second check into the lock, good practice to make this fully correct */
|
||||||
|
if (!matx_addon_checked) {
|
||||||
PyObject *mx_module = PyImport_ImportModule("materialx");
|
PyObject *mx_module = PyImport_ImportModule("materialx");
|
||||||
has_matx_addon = mx_module != nullptr;
|
has_matx_addon = mx_module != nullptr;
|
||||||
Py_XDECREF(mx_module);
|
Py_XDECREF(mx_module);
|
||||||
|
|
||||||
if (!has_matx_addon) {
|
if (!has_matx_addon) {
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
CLOG_WARN(LOG_RENDER_HYDRA_SCENE, "No MaterialX addon, materials won't be exported.");
|
CLOG_WARN(LOG_HYDRA_SCENE, "No MaterialX addon, materials won't be exported.");
|
||||||
|
}
|
||||||
|
matx_addon_checked = true;
|
||||||
}
|
}
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
matx_addon_checked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_matx_addon) {
|
if (!has_matx_addon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user