Skip to content

Commit

Permalink
Remove obsolete tracking of Object class reference
Browse files Browse the repository at this point in the history
  • Loading branch information
dvicini authored and njroussel committed Mar 15, 2023
1 parent f582af6 commit 283e994
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/python/main_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,16 @@ PYBIND11_MODULE(MODULE_NAME, m) {
auto casters = (std::vector<void *> *) (py::capsule)(mitsuba_ext.attr("casters"));
casters->push_back((void *) caster);

/* Increase the reference count of the `mitsuba.core.Object` type to make
sure libcore doesn't get destroyed before librender */
py::handle mts_object_type = mitsuba_ext.attr("Object");
mts_object_type.inc_ref();

/* Register a cleanup callback function that is invoked when
the 'mitsuba::Scene' Python type is garbage collected */
py::cpp_function cleanup_callback(
[mts_object_type](py::handle weakref) {
[](py::handle weakref) {
color_management_static_shutdown();
Scene::static_accel_shutdown();

/* The DrJit python module is responsible for cleaning up the
JIT state, so jit_shutdown() shouldn't be called here. */
weakref.dec_ref();

/* Decrease the reference count of the `mitsuba.core.Object` type as
the libcore can now be destroyed. Somehow the reference counter
needs to be decremented twice for this to work properly. */
mts_object_type.dec_ref();
mts_object_type.dec_ref();
}
);

Expand Down

0 comments on commit 283e994

Please sign in to comment.