From 0999a01b03d4ee727ff73661ec35c8c169926689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Mon, 14 Feb 2022 16:13:25 +0100 Subject: Fix T95320: CacheFile templates crash when used through Python The crash is caused as we did not check that the RNA pointer is null before trying to use it. This moves the existing checks from the modifier panels into the template functions so the logic is a bit centralized. --- source/blender/editors/interface/interface_templates.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8330f8c0db7..6a5d8d17af7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6397,6 +6397,10 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4]) void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr) { + if (RNA_pointer_is_null(fileptr)) { + return; + } + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); @@ -6406,6 +6410,10 @@ void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr) void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerRNA *fileptr) { + if (RNA_pointer_is_null(fileptr)) { + return; + } + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); @@ -6452,6 +6460,10 @@ void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerR void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr) { + if (RNA_pointer_is_null(fileptr)) { + return; + } + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); @@ -6502,6 +6514,10 @@ uiListType *UI_UL_cache_file_layers() void uiTemplateCacheFileLayers(uiLayout *layout, const bContext *C, PointerRNA *fileptr) { + if (RNA_pointer_is_null(fileptr)) { + return; + } + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); -- cgit v1.2.3