From 95b3c4c966f9baeb6f73b84568b7f03287e1a350 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 8 Dec 2020 13:47:37 +0100 Subject: File Browser: Refactor access to the selection parameters struct * Avoid direct access to `SpaceFile.params`, use a getter instead. This matters because once the asset-browser changes are in, there will be an alternative selection parameter object. The getter can return the correct one. * Rename the function to ensure the parameters. The old name `ED_fileselect_get_params()` wasn't a mere getter, it would create the parameters if necessary. Now we have an actual getter, so better be clear. * In some instances, I replaced the old "get" function with the new mere getter. So the ensure logic is called less often. However, in these cases we should be able to assume the selection parameters were created already as part of the editor creation routine. The term "active" in the new function names may seem a bit odd in the current context, but that is a preparation for the Asset Browser merge as well. Like said, there will be two file selection parameter objects in the space. --- source/blender/windowmanager/intern/wm_operators.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9eedd5b2faa..a5d23365df3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -84,6 +84,7 @@ #include "IMB_imbuf_types.h" +#include "ED_fileselect.h" #include "ED_numinput.h" #include "ED_screen.h" #include "ED_undo.h" @@ -496,7 +497,7 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr } case SPACE_FILE: { const SpaceFile *sfile = (SpaceFile *)space_data; - const FileSelectParams *params = sfile->params; + const FileSelectParams *params = ED_fileselect_get_active_params(sfile); TEST_PTR_DATA_TYPE("space_data", RNA_FileSelectParams, ptr, params); break; } -- cgit v1.2.3