Skip to content

Commit

Permalink
Set missing variant information before constructing Python plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
njroussel committed Feb 8, 2023
1 parent b253dde commit 93bb99b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion include/mitsuba/python/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@ PYBIND11_DECLARE_HOLDER_TYPE(T, mitsuba::ref<T>, true);
(void) new Class( \
name, #Name, variant, \
[=](const Properties &p) { \
py::object o = constructor(&p); \
/* The thread-local python variant information might not
have been set on this thread */ \
py::gil_scoped_acquire gil; \
py::module mi = py::module::import("mitsuba"); \
py::object py_variant = mi.attr("variant")(); \
if (py_variant.is(py::none()) || \
py_variant.cast<std::string>() != variant) \
mi.attr("set_variant")(variant); \
\
py::object o; \
{ \
py::gil_scoped_release release; \
o = constructor(&p); \
} \
\
ref<Name> o2 = o.cast<Name*>(); \
o.release(); \
return o2; \
Expand Down

0 comments on commit 93bb99b

Please sign in to comment.