Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
0228080a
Commit
0228080a
authored
Feb 03, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Adding // DANGER ZONE reminders.
parent
1e4f0fdc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
include/pybind11/detail/init.h
include/pybind11/detail/init.h
+3
-1
No files found.
include/pybind11/detail/init.h
View file @
0228080a
...
...
@@ -105,11 +105,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
// class gets to handle the destruction however it likes.
v_h
.
value_ptr
()
=
ptr
;
v_h
.
set_instance_registered
(
true
);
// To prevent init_instance from registering it
v_h
.
set_instance_registered
(
true
);
// SHORTCUT 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
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
.
set_instance_registered
(
false
);
// DANGER ZONE END.
construct_alias_from_cpp
<
Class
>
(
is_alias_constructible
<
Class
>
{},
v_h
,
std
::
move
(
*
ptr
));
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment