Cleanup: Add files for version independent versioning helpers
Adds `source/blender/blendloader/intern/versioning_common.cc` and `versioning_common.h` for version independent versioning functions. I only placed `do_versions_add_region_if_not_found()` in there for now. `blo_do_version_old_trackto_to_constraints()` could also be added, but that's so old, I prefer keeping that in `versioning_legacy.c`.
This commit is contained in:
parent
a4f840e15b
commit
8e84938dd0
|
@ -59,6 +59,7 @@ set(SRC
|
|||
intern/versioning_290.c
|
||||
intern/versioning_300.c
|
||||
intern/versioning_cycles.c
|
||||
intern/versioning_common.cc
|
||||
intern/versioning_defaults.c
|
||||
intern/versioning_dna.c
|
||||
intern/versioning_legacy.c
|
||||
|
@ -72,6 +73,7 @@ set(SRC
|
|||
BLO_undofile.h
|
||||
BLO_writefile.h
|
||||
intern/readfile.h
|
||||
intern/versioning_common.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
#include "BLO_readfile.h"
|
||||
#include "readfile.h"
|
||||
#include "versioning_common.h"
|
||||
|
||||
/* Make preferences read-only, use versioning_userdef.c. */
|
||||
#define U (*((const UserDef *)&U))
|
||||
|
@ -861,26 +862,6 @@ static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
|
||||
static ARegion *do_versions_add_region_if_not_found(ListBase *regionbase,
|
||||
int region_type,
|
||||
const char *name,
|
||||
int link_after_region_type)
|
||||
{
|
||||
ARegion *link_after_region = NULL;
|
||||
LISTBASE_FOREACH (ARegion *, region, regionbase) {
|
||||
if (region->regiontype == region_type) {
|
||||
return NULL;
|
||||
}
|
||||
if (region->regiontype == link_after_region_type) {
|
||||
link_after_region = region;
|
||||
}
|
||||
}
|
||||
ARegion *new_region = MEM_callocN(sizeof(ARegion), name);
|
||||
new_region->regiontype = region_type;
|
||||
BLI_insertlinkafter(regionbase, link_after_region, new_region);
|
||||
return new_region;
|
||||
}
|
||||
|
||||
/* NOLINTNEXTLINE: readability-function-size */
|
||||
void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup blenloader
|
||||
*/
|
||||
/* allow readfile to use deprecated functionality */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "versioning_common.h"
|
||||
|
||||
ARegion *do_versions_add_region_if_not_found(ListBase *regionbase,
|
||||
int region_type,
|
||||
const char *name,
|
||||
int link_after_region_type)
|
||||
{
|
||||
ARegion *link_after_region = NULL;
|
||||
LISTBASE_FOREACH (ARegion *, region, regionbase) {
|
||||
if (region->regiontype == region_type) {
|
||||
return NULL;
|
||||
}
|
||||
if (region->regiontype == link_after_region_type) {
|
||||
link_after_region = region;
|
||||
}
|
||||
}
|
||||
|
||||
ARegion *new_region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), name));
|
||||
new_region->regiontype = region_type;
|
||||
BLI_insertlinkafter(regionbase, link_after_region, new_region);
|
||||
return new_region;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup blenloader
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct ARegion;
|
||||
struct ListBase;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ARegion *do_versions_add_region_if_not_found(struct ListBase *regionbase,
|
||||
int region_type,
|
||||
const char *name,
|
||||
int link_after_region_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue