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.
This commit is contained in:
parent
65d4c58060
commit
0999a01b03
Notes:
blender-bot
2023-02-14 02:43:21 +01:00
Referenced by issue #95320, PyAPI: Crash when using template_cache_file_* if no cache file is selected
|
@ -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);
|
||||
|
||||
|
|
|
@ -343,10 +343,6 @@ static void velocity_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
return;
|
||||
}
|
||||
|
||||
if (RNA_pointer_is_null(&fileptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiTemplateCacheFileVelocity(layout, &fileptr);
|
||||
uiItemR(layout, ptr, "velocity_scale", 0, NULL, ICON_NONE);
|
||||
|
@ -364,10 +360,6 @@ static void time_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
return;
|
||||
}
|
||||
|
||||
if (RNA_pointer_is_null(&fileptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiTemplateCacheFileTimeSettings(layout, &fileptr);
|
||||
}
|
||||
|
@ -384,10 +376,6 @@ static void render_procedural_panel_draw(const bContext *C, Panel *panel)
|
|||
return;
|
||||
}
|
||||
|
||||
if (RNA_pointer_is_null(&fileptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiTemplateCacheFileProcedural(layout, C, &fileptr);
|
||||
}
|
||||
|
@ -404,10 +392,6 @@ static void override_layers_panel_draw(const bContext *C, Panel *panel)
|
|||
return;
|
||||
}
|
||||
|
||||
if (RNA_pointer_is_null(&fileptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiTemplateCacheFileLayers(layout, C, &fileptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue