|
Blender V4.5
|
#include <cstdlib>#include <cstring>#include <optional>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "DNA_brush_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_space_types.h"#include "BLI_fileops.h"#include "BLI_function_ref.hh"#include "BLI_listbase.h"#include "BLI_path_utils.hh"#include "BLI_string.h"#include "BLI_system.h"#include "BLI_time.h"#include "BLI_utildefines.h"#include "BLI_vector.hh"#include "BLI_vector_set.hh"#include "BLT_translation.hh"#include "IMB_colormanagement.hh"#include "BKE_addon.h"#include "BKE_appdir.hh"#include "BKE_blender.hh"#include "BKE_blender_version.h"#include "BKE_blendfile.hh"#include "BKE_bpath.hh"#include "BKE_colorband.hh"#include "BKE_context.hh"#include "BKE_global.hh"#include "BKE_idtype.hh"#include "BKE_layer.hh"#include "BKE_lib_id.hh"#include "BKE_lib_override.hh"#include "BKE_lib_query.hh"#include "BKE_lib_remap.hh"#include "BKE_library.hh"#include "BKE_main.hh"#include "BKE_main_idmap.hh"#include "BKE_main_namemap.hh"#include "BKE_preferences.h"#include "BKE_report.hh"#include "BKE_scene.hh"#include "BKE_screen.hh"#include "BKE_studiolight.h"#include "BKE_undo_system.hh"#include "BKE_workspace.hh"#include "BLO_read_write.hh"#include "BLO_readfile.hh"#include "BLO_userdef_default.h"#include "BLO_writefile.hh"#include "RE_pipeline.h"Go to the source code of this file.
Classes | |
| struct | ReuseOldBMainData |
Namespaces | |
| namespace | blender |
| namespace | blender::bke |
| namespace | blender::bke::blendfile |
Functions | |
Blend/Library Paths | |
| bool | BKE_blendfile_extension_check (const char *str) |
| bool | BKE_blendfile_library_path_explode (const char *path, char *r_dir, char **r_group, char **r_name) |
| bool | BKE_blendfile_is_readable (const char *path, ReportList *reports) |
Blend File IO (Preferences) | |
Application TemplatesWhen using app-templates, both regular & app-template preferences are used. Note that "regular" preferences refers to the preferences used with no app-template is active.
| |
| UserDef * | BKE_blendfile_userdef_read (const char *filepath, ReportList *reports) |
| UserDef * | BKE_blendfile_userdef_read_from_memory (const void *file_buf, int file_buf_size, ReportList *reports) |
| UserDef * | BKE_blendfile_userdef_from_defaults () |
| bool | BKE_blendfile_userdef_write (const char *filepath, ReportList *reports) |
| bool | BKE_blendfile_userdef_write_app_template (const char *filepath, ReportList *reports) |
| bool | BKE_blendfile_userdef_write_all (ReportList *reports) |
Blend File IO (WorkSpace) | |
| WorkspaceConfigFileData * | BKE_blendfile_workspace_config_read (const char *filepath, const void *file_buf, int file_buf_size, ReportList *reports) |
| void | BKE_blendfile_workspace_config_data_free (WorkspaceConfigFileData *workspace_config) |
Variables | |
Blend File Write (Partial) | |
| static CLG_LogRef | LOG_PARTIALWRITE = {"bke.blendfile.partial_write"} |
High level .blend file read/write, and functions for writing partial files (only selected data-blocks).
Definition in file blendfile.cc.
| bool BKE_blendfile_extension_check | ( | const char * | str | ) |
Check whether given path ends with a blend file compatible extension (.blend, .ble or .blend.gz).
| str | The path to check. |
Definition at line 84 of file blendfile.cc.
References BKE_blendfile_extension_check(), BLI_path_extension_check_array(), and str.
Referenced by BKE_blendfile_extension_check(), BKE_blendfile_library_path_explode(), ED_path_extension_type(), file_path_to_ui_path(), filelist_readjob_list_dir(), handle_load_file(), uiTemplateRecentFiles(), WM_lib_reload(), wm_lib_relocate_exec_do(), and wm_save_mainfile_check().
| bool BKE_blendfile_is_readable | ( | const char * | path, |
| ReportList * | reports ) |
Check whether a given path is actually a Blender-readable, valid .blend file.
Definition at line 153 of file blendfile.cc.
References BKE_blendfile_is_readable(), BLO_blendhandle_close(), BLO_blendhandle_from_file(), BlendFileReadReport::reports, and reports.
Referenced by BKE_blendfile_is_readable(), and file_draw_hint_if_invalid().
| bool BKE_blendfile_library_path_explode | ( | const char * | path, |
| char * | r_dir, | ||
| char ** | r_group, | ||
| char ** | r_name ) |
Try to explode given path into its 'library components' (i.e. a .blend file, id type/group, and data-block itself).
| path | the full path to explode. |
| r_dir | the string that'll contain path up to blend file itself ('library' path). WARNING! Must be at least FILE_MAX_LIBEXTRA long (it also stores group and name strings)! |
| r_group | a pointer within r_dir to the 'group' part of the path, if any ('\0' terminated). May be NULL. |
| r_name | a pointer within r_dir to the data-block name, if any ('\0' terminated). May be NULL. |
Definition at line 90 of file blendfile.cc.
References BKE_blendfile_extension_check(), BKE_blendfile_library_path_explode(), BLI_assert, BLI_is_dir(), BLI_is_file(), BLI_path_slash_rfind(), BLI_strncpy(), BLO_EMBEDDED_STARTUP_BLEND, BLO_GROUP_MAX, FILE_MAX_LIBEXTRA, MAX_ID_NAME, and STREQ.
Referenced by BKE_blendfile_library_path_explode(), file_directory_enter_handle(), fileentry_uiname(), filelist_checkdir_lib(), filelist_islibrary(), filelist_readjob_list_lib(), blender::asset_system::AssetRepresentation::full_library_path(), IMB_thumb_manage(), wm_id_linked_relocate_exec(), and wm_link_append_exec().
| BlendFileData * BKE_blendfile_read | ( | const char * | filepath, |
| const BlendFileReadParams * | params, | ||
| BlendFileReadReport * | reports ) |
Definition at line 1348 of file blendfile.cc.
References BKE_blendfile_read(), BKE_reports_prependf(), BLO_blendfiledata_free(), BLO_read_from_file(), G, handle_subversion_warning(), Main::is_read_invalid, BlendFileReadParams::is_startup, BlendFileData::main, printf, reports, and BlendFileReadParams::skip_flags.
Referenced by BKE_blendfile_read(), BKE_memfile_undo_decode(), blender::ed::vse::sequencer_clipboard_paste_exec(), WM_file_read(), and wm_homefile_read_ex().
| BlendFileData * BKE_blendfile_read_from_memfile | ( | Main * | bmain, |
| MemFile * | memfile, | ||
| const BlendFileReadParams * | params, | ||
| ReportList * | reports ) |
Definition at line 1393 of file blendfile.cc.
References BKE_blendfile_read_from_memfile(), BKE_main_blendfile_path(), BKE_reports_prepend(), BLO_blendfiledata_free(), BLO_read_from_memfile(), Main::is_read_invalid, BlendFileData::main, and reports.
Referenced by BKE_blendfile_read_from_memfile(), and BKE_memfile_undo_decode().
| BlendFileData * BKE_blendfile_read_from_memory | ( | const void * | file_buf, |
| int | file_buf_size, | ||
| const BlendFileReadParams * | params, | ||
| ReportList * | reports ) |
Definition at line 1373 of file blendfile.cc.
References BKE_blendfile_read_from_memory(), BKE_reports_prepend(), BLO_blendfiledata_free(), BLO_read_from_memory(), Main::is_read_invalid, BlendFileData::main, reports, and BlendFileReadParams::skip_flags.
Referenced by BKE_blendfile_read_from_memory(), and wm_homefile_read_ex().
| void BKE_blendfile_read_make_empty | ( | bContext * | C | ) |
Utility to make a file 'empty' used for startup to optionally give an empty file. Handy for tests.
Definition at line 1410 of file blendfile.cc.
References BKE_blendfile_read_make_empty(), BKE_id_delete(), C, CTX_data_main(), ELEM, FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, GS, ID_SCE, ID_SCR, ID_WM, and ID_WS.
Referenced by BKE_blendfile_read_make_empty(), and wm_homefile_read_ex().
| void BKE_blendfile_read_setup_readfile | ( | bContext * | C, |
| BlendFileData * | bfd, | ||
| const BlendFileReadParams * | params, | ||
| BlendFileReadWMSetupData * | wm_setup_data, | ||
| BlendFileReadReport * | reports, | ||
| bool | startup_update_defaults, | ||
| const char * | startup_app_template ) |
Shared setup function that makes the data from bfd into the current blend file, replacing the contents of #G.main. This uses the bfd returned by BKE_blendfile_read and similarly named functions.
This is done in a separate step so the caller may perform actions after it is known the file loaded correctly but before the file replaces the existing blend file contents.
Definition at line 1315 of file blendfile.cc.
References BKE_blendfile_read_setup_readfile(), BKE_reports_prepend(), BLO_blendfiledata_free(), BLO_READ_SKIP_DATA, BLO_update_defaults_startup_blend(), C, Main::is_read_invalid, BlendFileData::main, reports, setup_app_blend_file_data(), and BlendFileReadParams::skip_flags.
Referenced by BKE_blendfile_read_setup_readfile(), BKE_blendfile_read_setup_undo(), WM_file_read(), and wm_homefile_read_ex().
| void BKE_blendfile_read_setup_undo | ( | bContext * | C, |
| BlendFileData * | bfd, | ||
| const BlendFileReadParams * | params, | ||
| BlendFileReadReport * | reports ) |
Simpler version of BKE_blendfile_read_setup_readfile used when reading undo steps from memfile.
Definition at line 1340 of file blendfile.cc.
References BKE_blendfile_read_setup_readfile(), BKE_blendfile_read_setup_undo(), C, and reports.
Referenced by BKE_blendfile_read_setup_undo(), and BKE_memfile_undo_decode().
| UserDef * BKE_blendfile_userdef_from_defaults | ( | ) |
Definition at line 1500 of file blendfile.cc.
References UserDef::addons, ARRAY_SIZE, BKE_addon_new(), BKE_appdir_font_folder_default(), BKE_blendfile_userdef_from_defaults(), BKE_colorband_init(), BKE_preferences_asset_library_default_add(), BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(), BKE_preferences_extension_repo_add_defaults_all(), BKE_studiolight_default(), BLI_addtail(), BLI_path_slash_ensure(), BLI_system_memory_max_in_megabytes_int(), UserDef::coba_weight, UserDef::flag, UserDef::fontdir, i, UserDef::language, UserDef::light_ambient, UserDef::light_param, MEM_callocN(), MEM_mallocN(), UserDef::memcachelimit, min_ii(), bAddon::module, STRNCPY(), UserDef::themes, UserDef::transopts, U_default, U_theme_default, ULANGUAGE_AUTO, USER_SCRIPT_AUTOEXEC_DISABLE, USER_TR_IFACE, USER_TR_NEWDATANAME, and USER_TR_TOOLTIPS.
Referenced by BKE_blendfile_userdef_from_defaults(), BKE_blendfile_userdef_write_app_template(), and wm_homefile_read_ex().
| UserDef * BKE_blendfile_userdef_read | ( | const char * | filepath, |
| ReportList * | reports ) |
Only read the UserDef from a .blend.
Definition at line 1456 of file blendfile.cc.
References BKE_blendfile_userdef_read(), BKE_main_free(), BLO_read_from_file(), BLO_READ_SKIP_ALL, BLO_READ_SKIP_USERDEF, BlendFileData::main, BlendFileReadReport::reports, reports, and BlendFileData::user.
Referenced by BKE_blendfile_userdef_read(), BKE_blendfile_userdef_write_app_template(), and wm_homefile_read_ex().
| UserDef * BKE_blendfile_userdef_read_from_memory | ( | const void * | file_buf, |
| int | file_buf_size, | ||
| ReportList * | reports ) |
Definition at line 1477 of file blendfile.cc.
References BKE_blendfile_userdef_read_from_memory(), BKE_main_free(), BKE_reports_prepend(), BLO_read_from_memory(), BLO_READ_SKIP_ALL, BLO_READ_SKIP_USERDEF, BlendFileData::main, reports, and BlendFileData::user.
Referenced by BKE_blendfile_userdef_read_from_memory().
| bool BKE_blendfile_userdef_write | ( | const char * | filepath, |
| ReportList * | reports ) |
Only write the UserDef in a .blend.
Definition at line 1597 of file blendfile.cc.
References BKE_blendfile_userdef_write(), BLO_write_file(), MEM_callocN(), MEM_freeN(), reports, and BlendFileWriteParams::use_userdef.
Referenced by BKE_blendfile_userdef_write(), BKE_blendfile_userdef_write_all(), and BKE_blendfile_userdef_write_app_template().
| bool BKE_blendfile_userdef_write_all | ( | ReportList * | reports | ) |
Definition at line 1635 of file blendfile.cc.
References BKE_appdir_app_template_has_userpref(), BKE_appdir_folder_id_create(), BKE_blendfile_userdef_write(), BKE_blendfile_userdef_write_all(), BKE_blendfile_userdef_write_app_template(), BKE_report(), BLENDER_USER_CONFIG, BLENDER_USERPREF_FILE, BLI_path_join, FILE_MAX, G, printf, reports, RPT_ERROR, RPT_INFO, and U.
Referenced by BKE_blendfile_userdef_write_all(), WM_exit_ex(), and wm_userpref_write_exec().
| bool BKE_blendfile_userdef_write_app_template | ( | const char * | filepath, |
| ReportList * | reports ) |
Only write the UserDef in a .blend, merging with the existing blend file.
Definition at line 1614 of file blendfile.cc.
References BKE_blender_userdef_app_template_data_swap(), BKE_blender_userdef_data_free(), BKE_blendfile_userdef_from_defaults(), BKE_blendfile_userdef_read(), BKE_blendfile_userdef_write(), BKE_blendfile_userdef_write_app_template(), BLI_exists(), MEM_freeN(), reports, and U.
Referenced by BKE_blendfile_userdef_write_all(), and BKE_blendfile_userdef_write_app_template().
| void BKE_blendfile_workspace_config_data_free | ( | WorkspaceConfigFileData * | workspace_config | ) |
Definition at line 1745 of file blendfile.cc.
References BKE_blendfile_workspace_config_data_free(), BKE_main_free(), WorkspaceConfigFileData::main, and MEM_freeN().
Referenced by BKE_blendfile_workspace_config_data_free(), and workspace_add_menu().
| WorkspaceConfigFileData * BKE_blendfile_workspace_config_read | ( | const char * | filepath, |
| const void * | file_buf, | ||
| int | file_buf_size, | ||
| ReportList * | reports ) |
Definition at line 1712 of file blendfile.cc.
References BKE_blendfile_workspace_config_read(), BLO_read_from_file(), BLO_read_from_memory(), BLO_READ_SKIP_USERDEF, BlendFileData::main, WorkspaceConfigFileData::main, MEM_callocN(), BlendFileReadReport::reports, reports, Main::versionfile, Main::workspaces, and WorkspaceConfigFileData::workspaces.
Referenced by BKE_blendfile_workspace_config_read(), workspace_config_file_read(), and workspace_system_file_read().
| BLI_assert | ( | BLI_listbase_is_empty(new_lb)||!ID_IS_LINKED(new_lb->last) | ) |
References BLI_assert, BLI_listbase_is_empty(), ID_IS_LINKED, and new_lb.
| BLI_assert | ( | BLI_listbase_is_empty(old_lb)||!ID_IS_LINKED(old_lb->last) | ) |
Does a complete replacement of data in new_bmain by data from old_bmain. Original new data are moved to the old_bmain`, and will be freed together with it.
WARNING: Currently only expects to work on local data, won't work properly if some of the IDs of given type are linked.
NOTE: Unlike with reuse_editable_asset_bmain_data_for_blendfile, there is no support at all for potential dependencies of the IDs moved around. This is not expected to be necessary for the current use cases (UI-related IDs). */ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, const short id_code) { Main *new_bmain = reuse_data->new_bmain; Main *old_bmain = reuse_data->old_bmain;
ListBase *new_lb = which_libbase(new_bmain, id_code); ListBase *old_lb = which_libbase(old_bmain, id_code);
id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data);
/* NOTE: Full swapping is only supported for ID types that are assumed to be only local data-blocks (like UI-like ones). Otherwise, the swapping could fail in many funny ways.
References BLI_assert, BLI_listbase_is_empty(), and ID_IS_LINKED.
|
static |
Definition at line 182 of file blendfile.cc.
References BKE_bpath_foreach_path_main(), BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE, BLI_path_slash_native(), BPathForeachPathData::bmain, BPathForeachPathData::callback_function, clean_paths(), BPathForeachPathData::flag, foreach_path_clean_cb(), LISTBASE_FOREACH, Main::scenes, and BPathForeachPathData::user_data.
Referenced by clean_paths(), and setup_app_data().
| for | ( | ;discarded_id_iter ! | = nullptr; discarded_id_iter = static_cast<ID *>(discarded_id_iter->next) | ) |
Definition at line 634 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), and discarded_id_iter.
Referenced by blender::gpu::MSLGeneratorInterface::bake_shader_interface(), BlenderVolumeLoader::BlenderVolumeLoader(), BVHObjectSplit::BVHObjectSplit(), blender::ed::curves::contains(), blender::ed::pointcloud::contains(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_mixing(), do_vpaint_brush_blur_loops(), do_vpaint_brush_blur_verts(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size_cpu(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size_cpu(), GHOST_XrAction::GHOST_XrAction(), heat_calc_vnormals(), blender::nodes::LazyFunctionForEvaluateClosureNode::LazyFunctionForEvaluateClosureNode(), blender::nodes::LazyFunctionForGroupNode::LazyFunctionForGroupNode(), blender::nodes::LazyFunctionForReduceForeachGeometryElement::LazyFunctionForReduceForeachGeometryElement(), LightTree::LightTree(), blender::dot_export::NodeWithSocketsRef::NodeWithSocketsRef(), blender::bke::subdiv::precalc_uv_layer(), psys_thread_context_init_distribute(), blender::geometry::rotate_inside_square(), Freestyle::Stroke::Stroke(), and blender::opensubdiv::VolatileEvalOutput< SRC_VERTEX_BUFFER, EVAL_VERTEX_BUFFER, STENCIL_TABLE, PATCH_TABLE, EVALUATOR, DEVICE_CONTEXT >::VolatileEvalOutput().
| FOREACH_MAIN_LISTBASE_ID_BEGIN | ( | new_lb | , |
| reused_id_iter | ) |
Definition at line 640 of file blendfile.cc.
References blender::bke::id::IDRemapper::add_overwrite(), BKE_lib_libblock_session_uid_renew(), FOREACH_MAIN_LISTBASE_ID_BEGIN, new_lb, and reused_id_iter.
|
static |
Definition at line 171 of file blendfile.cc.
References BLI_path_slash_native(), BLI_strncpy(), foreach_path_clean_cb(), and STREQ.
Referenced by clean_paths(), and foreach_path_clean_cb().
|
static |
Definition at line 1302 of file blendfile.cc.
References BKE_reportf(), BLENDER_FILE_SUBVERSION, BLENDER_FILE_VERSION, handle_subversion_warning(), main, reports, and RPT_WARNING.
Referenced by BKE_blendfile_read(), and handle_subversion_warning().
|
static |
Definition at line 394 of file blendfile.cc.
References blender::bke::id::IDRemapper::apply(), BKE_main_namemap_destroy(), BLI_assert_unreachable, Library::id, ID_REMAP_APPLY_DEFAULT, ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_RESULT_SOURCE_UNASSIGNED, ID_REMAP_RESULT_SOURCE_UNAVAILABLE, LIBRARY_ASSET_EDITABLE, LIBRARY_ASSET_FILE_WRITABLE, result, reuse_bmain_data_dependencies_new_library_get(), reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), and Library::runtime.
Referenced by reuse_bmain_data_dependencies_new_library_get(), reuse_editable_asset_bmain_data_dependencies_process_cb(), and reuse_editable_asset_bmain_data_for_blendfile().
|
static |
Detect and fix invalid usages of locale IDs by linked ones (or as reference of liboverrides).
Definition at line 804 of file blendfile.cc.
References BKE_lib_override_library_free(), BKE_library_foreach_ID_link(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY_REAL, IDWALK_NOP, new_bmain, ReuseOldBMainData::new_bmain, ID::override_library, IDOverrideLibrary::reference, reuse_bmain_data_invalid_local_usages_fix(), and reuse_bmain_data_invalid_local_usages_fix_cb().
Referenced by reuse_bmain_data_invalid_local_usages_fix(), and setup_app_data().
|
static |
Definition at line 762 of file blendfile.cc.
References LibraryIDLinkCallbackData::cb_flag, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY_REAL, LibraryIDLinkCallbackData::id_pointer, id_us_min(), IDWALK_CB_EMBEDDED, IDWALK_CB_EMBEDDED_NOT_OWNING, IDWALK_CB_USER, IDWALK_RET_NOP, ID::override_library, LibraryIDLinkCallbackData::owner_id, IDOverrideLibrary::reference, and reuse_bmain_data_invalid_local_usages_fix_cb().
Referenced by reuse_bmain_data_invalid_local_usages_fix(), and reuse_bmain_data_invalid_local_usages_fix_cb().
|
static |
Search for all libraries in old_bmain that are also in new_bmain (i.e. different Library IDs having the same absolute filepath), and create a remapping rule for these.
NOTE: The case where the old_bmain would be a library in the newly read one is not handled here, as it does not create explicit issues. The local data from old_bmain is either discarded, or added to the new_bmain as local data as well. Worst case, there will be a double of a linked data as a local one, without any known relationships between them. In practice, this latter case is not expected to commonly happen.
Definition at line 268 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), ReuseOldBMainData::is_libraries_remapped, LISTBASE_FOREACH, new_bmain, ReuseOldBMainData::new_bmain, old_bmain, ReuseOldBMainData::old_bmain, ReuseOldBMainData::remapper, reuse_bmain_data_remapper_ensure(), and STREQ.
Referenced by reuse_bmain_data_dependencies_new_library_get(), reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_dependencies_process_cb(), reuse_editable_asset_bmain_data_for_blendfile(), swap_old_bmain_data_for_blendfile_dependencies_process_cb(), and swap_wm_data_for_blendfile().
|
static |
Definition at line 308 of file blendfile.cc.
References BLI_assert, BLI_assert_msg, ELEM, blender::bke::id::IDRemapper::get_mapping_result(), ID_REMAP_APPLY_DEFAULT, ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_RESULT_SOURCE_UNASSIGNED, ID_REMAP_RESULT_SOURCE_UNAVAILABLE, result, and reuse_bmain_data_remapper_is_id_remapped().
Referenced by reuse_bmain_data_remapper_is_id_remapped(), reuse_editable_asset_bmain_data_dependencies_process_cb(), and swap_old_bmain_data_for_blendfile_dependencies_process_cb().
|
static |
Definition at line 322 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), BKE_id_new_name_validate(), BKE_lib_libblock_session_uid_renew(), BKE_main_namemap_remove_id(), BLI_addtail(), BLI_assert, BLI_findindex(), BLI_remlink_safe(), ELEM, GS, ID_FLAG_EMBEDDED_DATA, ID_IS_LINKED, id_sort_by_name(), LISTBASE_FOREACH_BACKWARD, new_bmain, ReuseOldBMainData::new_bmain, new_lb, old_bmain, ReuseOldBMainData::old_bmain, RenameExistingNever, reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), STREQ, and which_libbase().
Referenced by reuse_bmain_data_dependencies_new_library_get(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_dependencies_process_cb(), and reuse_editable_asset_bmain_data_for_blendfile().
|
static |
Definition at line 434 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), BLI_assert_unreachable, GS, ID_LI, LibraryIDLinkCallbackData::id_pointer, ID_TYPE_SUPPORTS_ASSET_EDITABLE, IDWALK_RET_NOP, IDWALK_RET_STOP_RECURSION, reuse_bmain_data_dependencies_new_library_get(), reuse_bmain_data_remapper_ensure(), reuse_bmain_data_remapper_is_id_remapped(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_dependencies_process_cb(), and LibraryIDLinkCallbackData::user_data.
Referenced by reuse_editable_asset_bmain_data_dependencies_process_cb(), and reuse_editable_asset_bmain_data_for_blendfile().
|
static |
Selectively 'import' data from old Main into new Main, provided it does not conflict with data already present in the new Main (name-wise and library-wise).
Dependencies from moved over old data are also imported into the new Main, (unless, in case of linked data, a matching linked ID is already available in new Main).
When a conflict is found, usages of the conflicted ID by the old data are stored in the remapper of ReuseOldBMainData to be remapped to the matching data in the new Main later.
NOTE: This function will never remove any original new data from the new Main, it only moves (some of) the old data to the new Main.
Definition at line 509 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), BKE_library_foreach_ID_link(), FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, ID_IS_LINKED, IDWALK_DO_LIBRARY_POINTER, IDWALK_RECURSE, ID::lib, LIBRARY_ASSET_EDITABLE, new_bmain, ReuseOldBMainData::new_bmain, old_bmain, ReuseOldBMainData::old_bmain, reuse_bmain_data_dependencies_new_library_get(), reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_dependencies_process_cb(), reuse_editable_asset_bmain_data_for_blendfile(), Library::runtime, and which_libbase().
Referenced by reuse_editable_asset_bmain_data_for_blendfile(), and setup_app_data().
|
static |
Definition at line 485 of file blendfile.cc.
References LIBRARY_ASSET_EDITABLE, LISTBASE_FOREACH, old_bmain, ReuseOldBMainData::old_bmain, and reuse_editable_asset_needed().
Referenced by reuse_editable_asset_needed(), and setup_app_data().
|
static |
Definition at line 1288 of file blendfile.cc.
References BLO_READ_SKIP_DATA, BLO_READ_SKIP_USERDEF, C, reports, setup_app_blend_file_data(), setup_app_data(), setup_app_userdef(), and BlendFileReadParams::skip_flags.
Referenced by BKE_blendfile_read_setup_readfile(), and setup_app_blend_file_data().
|
static |
This function runs after loading blend-file data and is responsible for setting up the context (the active view-layer, scene & work-space).
When loading a blend-file without it's UI (G_FILE_NO_UI), the existing screen-data needs to point to the newly loaded blend-file data.
| bfd | Blend file data, freed by this function on exit. |
Definition at line 919 of file blendfile.cc.
References BKE_blender_globals_main_replace(), BKE_idtype_get_info_from_idtype_index(), BKE_idtype_idcode_to_name(), BKE_lib_override_library_main_operations_create(), BKE_lib_override_library_main_resync(), BKE_libblock_remap_multiple_raw(), BKE_main_id_refcount_recompute(), BKE_main_idmap_create(), BKE_main_idmap_destroy(), BKE_main_namemap_validate(), BKE_report(), BKE_scene_add(), BKE_scene_set_background(), BKE_screen_gizmo_tag_refresh(), BKE_screen_runtime_refresh_for_blendfile(), BKE_screen_view3d_scene_sync(), BKE_view_layer_default_view(), BLI_assert, BLI_time_now_seconds(), BLO_read_do_version_after_setup(), BLO_readfile_id_runtime_data_free_all(), BLO_reportf_wrap(), BPY_context_update(), C, clean_paths(), CTX_data_main_set(), CTX_data_scene_set(), CTX_py_init_get(), CTX_wm_area_set(), CTX_wm_manager(), CTX_wm_manager_set(), CTX_wm_region_popup_set(), CTX_wm_region_set(), CTX_wm_screen(), CTX_wm_screen_set(), CTX_wm_window(), BlendFileData::cur_view_layer, BlendFileData::curscene, BlendFileData::curscreen, ELEM, BlendFileData::fileflags, BlendFileData::filepath, Main::filepath, ListBase::first, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, G, G_FILE_ASSET_EDIT_FILE, G_FILE_FLAG_ALL_RUNTIME, G_FILE_NO_UI, G_FILE_RECOVER_READ, G_FLAG_ALL_READFILE, G_FLAG_ALL_RUNTIME, G_MAIN, BlendFileData::globalf, GS, IDTypeInfo::id_code, ID_IS_LINKED, ReuseOldBMainData::id_map, ID_REMAP_FORCE_UI_POINTERS, ID_REMAP_SKIP_UPDATE_TAGGING, ID_REMAP_SKIP_USER_CLEAR, ID_REMAP_SKIP_USER_REFCOUNT, ID_SCR, ID_TAG_MISSING, ID_TYPE_SUPPORTS_ASSET_EDITABLE, ID_WM, ID_WS, IMB_colormanagement_check_file_config(), INDEX_ID_MAX, Main::is_asset_edit_file, blender::bke::liboverride::is_auto_resync_enabled(), BlendFileReadParams::is_factory_settings, BlendFileReadParams::is_startup, ID::lib, LISTBASE_FOREACH, BlendFileData::main, MAIN_IDMAP_TYPE_NAME, ID::name, ReuseOldBMainData::new_bmain, ReuseOldBMainData::old_bmain, RE_FreeAllPersistentData(), RE_FreeAllRenderResults(), RE_FreeInteractiveCompositorRenders(), Main::recovered, ReuseOldBMainData::remapper, reports, reuse_bmain_data_invalid_local_usages_fix(), reuse_editable_asset_bmain_data_for_blendfile(), reuse_editable_asset_needed(), RPT_, RPT_INFO, RPT_WARNING, Library::runtime, wmWindow::scene, Main::scenes, Main::screens, setup_app_data(), STEP_INVALID, STRNCPY(), swap_old_bmain_data_dependencies_process(), swap_wm_data_for_blendfile(), ID::tag, BlendFileReadParams::undo_direction, unpin_file_local_grease_pencil_brush_materials(), Main::wm, wm_data_consistency_ensure(), wm_scene_is_visible(), and ReuseOldBMainData::wm_setup_data.
Referenced by setup_app_blend_file_data(), and setup_app_data().
|
static |
Definition at line 207 of file blendfile.cc.
References BKE_blender_userdef_data_set_and_free(), setup_app_userdef(), U, BlendFileData::user, and USER_SCRIPT_AUTOEXEC_DISABLE.
Referenced by setup_app_blend_file_data(), and setup_app_userdef().
|
static |
Definition at line 738 of file blendfile.cc.
References BKE_library_foreach_ID_link(), BLI_assert, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, ReuseOldBMainData::id_map, IDWALK_DO_LIBRARY_POINTER, IDWALK_INCLUDE_UI, IDWALK_READONLY, new_bmain, ReuseOldBMainData::new_bmain, new_lb, swap_old_bmain_data_dependencies_process(), swap_old_bmain_data_for_blendfile_dependencies_process_cb(), and which_libbase().
Referenced by setup_app_data(), and swap_old_bmain_data_dependencies_process().
|
static |
Definition at line 712 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), BKE_main_idmap_lookup_id(), BLI_assert, ReuseOldBMainData::id_map, LibraryIDLinkCallbackData::id_pointer, IDWALK_RET_NOP, reuse_bmain_data_remapper_ensure(), reuse_bmain_data_remapper_is_id_remapped(), swap_old_bmain_data_for_blendfile_dependencies_process_cb(), and LibraryIDLinkCallbackData::user_data.
Referenced by swap_old_bmain_data_dependencies_process(), and swap_old_bmain_data_for_blendfile_dependencies_process_cb().
|
static |
Similar to #swap_old_bmain_data_for_blendfile, but with special handling for WM ID. Tightly related to further WM post-processing from calling WM code (see WM_file_read and wm_homefile_read_ex).
Definition at line 656 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), BKE_lib_id_swap_full(), BLI_addhead(), BLI_assert, BLI_listbase_count_at_most(), BLI_remlink(), ListBase::first, wmWindowManager::id, ID_REMAP_FORCE_UI_POINTERS, ID_REMAP_SKIP_NEVER_NULL_USAGE, ID_REMAP_SKIP_UPDATE_TAGGING, ID_REMAP_SKIP_USER_REFCOUNT, ID_WM, wmWindowManager::init_flag, new_bmain, ReuseOldBMainData::new_bmain, old_bmain, ReuseOldBMainData::old_bmain, BlendFileReadWMSetupData::old_wm, reuse_bmain_data_remapper_ensure(), swap_wm_data_for_blendfile(), WM_INIT_FLAG_WINDOW, and ReuseOldBMainData::wm_setup_data.
Referenced by setup_app_data(), and swap_wm_data_for_blendfile().
|
static |
Grease pencil brushes may have a material pinned that is from the current file. Moving local scene data to a different Main is tricky, so in that case, unpin the material.
Definition at line 555 of file blendfile.cc.
References Main::brushes, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, GP_BRUSH_MATERIAL_PINNED, ID_IS_LINKED, ReuseOldBMainData::old_bmain, and unpin_file_local_grease_pencil_brush_materials().
Referenced by setup_app_data(), and unpin_file_local_grease_pencil_brush_materials().
|
static |
Definition at line 833 of file blendfile.cc.
References bScreen::areabase, BKE_workspace_active_screen_get(), Scene::camera, View3D::camera, ListBase::first, LISTBASE_FOREACH, Base::local_view_bits, View3D::local_view_uid, RegionView3D::localvd, View3D::localvd, MEM_freeN(), MEM_SAFE_FREE, Base::next, ViewLayer::object_bases, RGN_TYPE_WINDOW, View3D::scenelock, SPACE_VIEW3D, view3d_data_consistency_ensure(), and wmWindow::workspace_hook.
Referenced by view3d_data_consistency_ensure(), and wm_data_consistency_ensure().
| while | ( | ! | ELEMnullptr, discarded_id_iter, reused_id_iter | ) |
Definition at line 614 of file blendfile.cc.
References blender::bke::id::IDRemapper::add(), discarded_id_iter, ELEM, ID::name, ID::next, and reused_id_iter.
|
static |
Definition at line 886 of file blendfile.cc.
References BKE_view_layer_find(), LISTBASE_FOREACH, ViewLayer::name, STRNCPY(), view3d_data_consistency_ensure(), wmWindowManager::windows, and wm_data_consistency_ensure().
Referenced by setup_app_data(), and wm_data_consistency_ensure().
|
static |
Definition at line 197 of file blendfile.cc.
References LISTBASE_FOREACH, and wm_scene_is_visible().
Referenced by setup_app_data(), and wm_scene_is_visible().
Definition at line 612 of file blendfile.cc.
| FOREACH_MAIN_LISTBASE_ID_END |
Definition at line 648 of file blendfile.cc.
|
static |
| BKE_main_namemap_clear* new_bmain |
Definition at line 603 of file blendfile.cc.
Referenced by blo_bhead_prev(), BLO_read_do_version_after_setup(), do_versions_after_setup(), read_undo_remap_noundo_data(), read_undo_reuse_noundo_local_ids(), reuse_bmain_data_invalid_local_usages_fix(), reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_for_blendfile(), swap_old_bmain_data_dependencies_process(), and swap_wm_data_for_blendfile().
| std::swap* new_lb |
Definition at line 598 of file blendfile.cc.
Referenced by BLI_assert(), FOREACH_MAIN_LISTBASE_ID_BEGIN(), read_libblock_undo_restore_at_old_address(), read_libblock_undo_restore_identical(), read_undo_reuse_noundo_local_ids(), reuse_bmain_move_id(), swap_old_bmain_data_dependencies_process(), and UI_context_copy_to_selected_list().
| BKE_main_namemap_clear* old_bmain |
Definition at line 602 of file blendfile.cc.
Referenced by BKE_main_idmap_create(), read_libblock_undo_restore_at_old_address(), read_libblock_undo_restore_identical(), read_undo_reuse_noundo_local_ids(), reuse_bmain_data_remapper_ensure(), reuse_bmain_move_id(), reuse_editable_asset_bmain_data_for_blendfile(), reuse_editable_asset_needed(), and swap_wm_data_for_blendfile().
Definition at line 613 of file blendfile.cc.
Referenced by FOREACH_MAIN_LISTBASE_ID_BEGIN(), and while().