Fix: crash showing depsgraph items in the outliner

Part of a fix for #145877 which exposed multiple crashes in the
outliner.

Hide depsgraph collections that are dynamically allocated,
causing access to freed memory form the outliner.

Ref !145955
This commit is contained in:
Campbell Barton
2025-10-02 15:09:51 +10:00
parent 44d04ad857
commit bbaf626abb
3 changed files with 20 additions and 0 deletions

View File

@@ -446,6 +446,15 @@ void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag);
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag);
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag);
void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag);
/**
* In some cases showing properties in the outliner crashes.
* It's a bug that occurs when accessing a value re-allocates
* memory which may already be referenced by other RNA.
* See: #145877.
*/
void RNA_def_property_flag_hide_from_ui_workaround(PropertyRNA *prop);
/**
* Add the property-tags passed as \a tags to \a prop (if valid).
*

View File

@@ -1594,6 +1594,13 @@ void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
}
}
void RNA_def_property_flag_hide_from_ui_workaround(PropertyRNA *prop)
{
/* Re-use the hidden flag.
* This function is mainly used so it's clear that this is a workaround. */
RNA_def_property_flag(prop, PROP_HIDDEN);
}
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
{
prop->flag &= ~flag;

View File

@@ -800,6 +800,7 @@ static void rna_def_depsgraph(BlenderRNA *brna)
prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_flag_hide_from_ui_workaround(prop);
RNA_def_property_collection_funcs(prop,
"rna_Depsgraph_ids_begin",
"rna_Depsgraph_ids_next",
@@ -813,6 +814,7 @@ static void rna_def_depsgraph(BlenderRNA *brna)
prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag_hide_from_ui_workaround(prop);
RNA_def_property_collection_funcs(prop,
"rna_Depsgraph_objects_begin",
"rna_Depsgraph_objects_next",
@@ -826,6 +828,7 @@ static void rna_def_depsgraph(BlenderRNA *brna)
prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "DepsgraphObjectInstance");
RNA_def_property_flag_hide_from_ui_workaround(prop);
RNA_def_property_collection_funcs(prop,
"rna_Depsgraph_object_instances_begin",
"rna_Depsgraph_object_instances_next",
@@ -843,6 +846,7 @@ static void rna_def_depsgraph(BlenderRNA *brna)
prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "DepsgraphUpdate");
RNA_def_property_flag_hide_from_ui_workaround(prop);
RNA_def_property_collection_funcs(prop,
"rna_Depsgraph_updates_begin",
"rna_Depsgraph_ids_next",