mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 08:32:02 +00:00
Merge branch 'bakein_prep_on_master' into bakein
This commit is contained in:
commit
4aa2f6b8eb
@ -129,11 +129,13 @@ void construct(value_and_holder &v_h, Cpp<Class> *ptr, bool need_alias) {
|
|||||||
// the holder and destruction happens when we leave the C++ scope, and the holder
|
// the holder and destruction happens when we leave the C++ scope, and the holder
|
||||||
// class gets to handle the destruction however it likes.
|
// class gets to handle the destruction however it likes.
|
||||||
v_h.value_ptr() = ptr;
|
v_h.value_ptr() = ptr;
|
||||||
v_h.set_instance_registered(true); // To prevent init_instance from registering it
|
v_h.set_instance_registered(true); // Trick to prevent init_instance from registering it
|
||||||
|
// DANGER ZONE BEGIN: exceptions will leave v_h in an invalid state.
|
||||||
v_h.type->init_instance(v_h.inst, nullptr); // Set up the holder
|
v_h.type->init_instance(v_h.inst, nullptr); // Set up the holder
|
||||||
Holder<Class> temp_holder(std::move(v_h.holder<Holder<Class>>())); // Steal the holder
|
Holder<Class> temp_holder(std::move(v_h.holder<Holder<Class>>())); // Steal the holder
|
||||||
v_h.type->dealloc(v_h); // Destroys the moved-out holder remains, resets value ptr to null
|
v_h.type->dealloc(v_h); // Destroys the moved-out holder remains, resets value ptr to null
|
||||||
v_h.set_instance_registered(false);
|
v_h.set_instance_registered(false);
|
||||||
|
// DANGER ZONE END.
|
||||||
|
|
||||||
construct_alias_from_cpp<Class>(is_alias_constructible<Class>{}, v_h, std::move(*ptr));
|
construct_alias_from_cpp<Class>(is_alias_constructible<Class>{}, v_h, std::move(*ptr));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user