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 <julian@blender.org>2021-06-15 20:28:24 +0300
committerJulian Eisel <julian@blender.org>2021-06-15 20:33:00 +0300
commit8e84938dd0428c0aa9705077b017bad85d490cc9 (patch)
tree6546c5c341b06b1ad952dd4446d21a4b0aa82793 /source/blender/blenloader/intern/versioning_common.cc
parenta4f840e15bf0a3692741876e27766d606e6d942c (diff)
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`.
Diffstat (limited to 'source/blender/blenloader/intern/versioning_common.cc')
-rw-r--r--source/blender/blenloader/intern/versioning_common.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc
new file mode 100644
index 00000000000..da3ff08a7dd
--- /dev/null
+++ b/source/blender/blenloader/intern/versioning_common.cc
@@ -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;
+}