Fix #132982: Guard nullptr in rna_Space_view2d_sync_get

`area` returned by `rna_area_from_space` can be null, this can cause
crashes when viewing "Local View" property in the Outliner. Now fixed.

Pull Request: https://projects.blender.org/blender/blender/pulls/132983
This commit is contained in:
YimingWu
2025-01-14 07:22:33 +01:00
committed by YimingWu
parent 14e6e84fb7
commit 8dc3735c3d

View File

@@ -896,6 +896,10 @@ static bool rna_Space_view2d_sync_get(PointerRNA *ptr)
ARegion *region;
area = rna_area_from_space(ptr); /* can be nullptr */
if (area == nullptr) {
return false;
}
if (area->spacetype == SPACE_CLIP) {
region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
}
@@ -916,7 +920,11 @@ static void rna_Space_view2d_sync_set(PointerRNA *ptr, bool value)
ARegion *region;
area = rna_area_from_space(ptr); /* can be nullptr */
if ((area != nullptr) && !UI_view2d_area_supports_sync(area)) {
if (!area) {
return;
}
if (!UI_view2d_area_supports_sync(area)) {
BKE_reportf(nullptr,
RPT_ERROR,
"'show_locked_time' is not supported for the '%s' editor",
@@ -947,6 +955,10 @@ static void rna_Space_view2d_sync_update(Main * /*bmain*/, Scene * /*scene*/, Po
ARegion *region;
area = rna_area_from_space(ptr); /* can be nullptr */
if (area == nullptr) {
return;
}
if (area->spacetype == SPACE_CLIP) {
region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
}