Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2019-09-20 16:35:28 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-09-20 16:35:28 +0300
commitb20182e334180d751acff4565d2cf061dcb90add (patch)
treede1e3124d21cc98fce6b46773aff8d2e5c8249b9 /source/blender/editors/space_file/space_file.c
parentd1cc340e56691cb82e444289415ede24ba4d2bc0 (diff)
Refactor: Ensure there's always a valid file editor tool region
So far the file browser code had some lazy creation for the tool region, even though it should always be there. The only reason I can see for this is compatiblity. So I simply added versioning code to add the region in case it's not there. Now we should be able to savely assume the tool region to be there, whithout any unusual lazy-creation.
Diffstat (limited to 'source/blender/editors/space_file/space_file.c')
-rw-r--r--source/blender/editors/space_file/space_file.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index ef7586e9432..d59a75e5e05 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -55,27 +55,6 @@
#include "filelist.h"
#include "GPU_framebuffer.h"
-static ARegion *file_tools_region_create(ListBase *regionbase, ARegion *ar_prev)
-{
- ARegion *ar = MEM_callocN(sizeof(ARegion), "tools region for file");
- BLI_insertlinkafter(regionbase, ar_prev, ar);
- ar->regiontype = RGN_TYPE_TOOLS;
- ar->alignment = RGN_ALIGN_LEFT;
-
- return ar;
-}
-
-ARegion *file_tools_region_ensure(ScrArea *sa, ARegion *ar_prev)
-{
- ARegion *ar;
-
- if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL) {
- return ar;
- }
-
- return file_tools_region_create(&sa->regionbase, ar_prev);
-}
-
static ARegion *file_tools_options_toggle_region_ensure(ScrArea *sa, ARegion *ar_prev)
{
ARegion *ar;
@@ -154,7 +133,10 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
/* Tools region */
- file_tools_region_create(&sfile->regionbase, ar);
+ ar = MEM_callocN(sizeof(ARegion), "tools region for file");
+ BLI_addtail(&sfile->regionbase, ar);
+ ar->regiontype = RGN_TYPE_TOOLS;
+ ar->alignment = RGN_ALIGN_LEFT;
/* Options toggle, tool props and execute region are added as needed, see file_refresh(). */
@@ -276,18 +258,12 @@ static void file_ensure_valid_region_state(bContext *C,
SpaceFile *sfile,
FileSelectParams *params)
{
- ARegion *ar_ui = BKE_area_find_region_type(sa, RGN_TYPE_UI);
ARegion *ar_tools_upper = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
ARegion *ar_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE);
ARegion *ar_tools_lower;
bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */
- if (ar_tools_upper == NULL) {
- ar_tools_upper = file_tools_region_ensure(sa, ar_ui);
- needs_init = true;
- }
-
/* If there's an file-operation, ensure we have the option and execute region */
if (sfile->op && (ar_props == NULL)) {
ar_tools_lower = file_tools_options_toggle_region_ensure(sa, ar_tools_upper);