mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
interrogate: generated property getter should copy in some cases
This is to fix eg. public ButtonHandle members from being returned as const reference, which means they won't outlive the struct they are accessed on, a recipe for obscure crashes. The is_trivial() criterium for this to apply is admittedly really arbitrary; I haven't really figured out what the right criterium should be, but it's better than hardcoding ButtonHandle.
This commit is contained in:
parent
2ed4cd7ce6
commit
ad3b145951
@ -1389,7 +1389,8 @@ scan_element(CPPInstance *element, CPPStructType *struct_type,
|
||||
// We can only generate a getter and a setter if we can talk about the
|
||||
// type it is.
|
||||
|
||||
if (parameter_type->as_struct_type() != nullptr) {
|
||||
if (parameter_type->as_struct_type() != nullptr &&
|
||||
!parameter_type->is_trivial()) {
|
||||
// Wrap the type in a const reference.
|
||||
parameter_type = TypeManager::wrap_const_reference(parameter_type);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user