diff --git a/source/blender/blenkernel/BKE_blendfile.hh b/source/blender/blenkernel/BKE_blendfile.hh index ef2107f5198..225178b4f14 100644 --- a/source/blender/blenkernel/BKE_blendfile.hh +++ b/source/blender/blenkernel/BKE_blendfile.hh @@ -209,7 +209,7 @@ class PartialWriteContext : NonCopyable, NonMovable { /* Passing a reference root filepath is mandatory, for remapping of relative paths to work as * expected. */ PartialWriteContext() = delete; - PartialWriteContext(StringRefNull reference_root_filepath); + PartialWriteContext(Main &reference_main); ~PartialWriteContext(); /** diff --git a/source/blender/blenkernel/intern/asset_edit.cc b/source/blender/blenkernel/intern/asset_edit.cc index 90ad2c799a1..f964a0ac6ce 100644 --- a/source/blender/blenkernel/intern/asset_edit.cc +++ b/source/blender/blenkernel/intern/asset_edit.cc @@ -160,7 +160,7 @@ static bool asset_write_in_library(Main &bmain, ID &id = const_cast(id_const); - PartialWriteContext lib_write_ctx{BKE_main_blendfile_path(&bmain)}; + PartialWriteContext lib_write_ctx{bmain}; ID *new_id = lib_write_ctx.id_add(&id, {(PartialWriteContext::IDAddOperations::MAKE_LOCAL | PartialWriteContext::IDAddOperations::SET_FAKE_USER | diff --git a/source/blender/blenkernel/intern/blendfile.cc b/source/blender/blenkernel/intern/blendfile.cc index ae1bb46d196..57522aabd47 100644 --- a/source/blender/blenkernel/intern/blendfile.cc +++ b/source/blender/blenkernel/intern/blendfile.cc @@ -1741,12 +1741,13 @@ static CLG_LogRef LOG_PARTIALWRITE = {"blend.partial_write"}; namespace blender::bke::blendfile { -PartialWriteContext::PartialWriteContext(StringRefNull reference_root_filepath) - : reference_root_filepath_(reference_root_filepath) +PartialWriteContext::PartialWriteContext(Main &reference_main) + : reference_root_filepath_(BKE_main_blendfile_path(&reference_main)) { if (!reference_root_filepath_.empty()) { STRNCPY(this->bmain.filepath, reference_root_filepath_.c_str()); } + this->bmain.colorspace = reference_main.colorspace; /* Only for IDs matching existing data in current G_MAIN. */ matching_uid_map_ = BKE_main_idmap_create(&this->bmain, false, nullptr, MAIN_IDMAP_TYPE_UID); /* For all IDs existing in the context. */ diff --git a/source/blender/editors/armature/pose_transform.cc b/source/blender/editors/armature/pose_transform.cc index f64fe1aa76a..9a090b3bcc8 100644 --- a/source/blender/editors/armature/pose_transform.cc +++ b/source/blender/editors/armature/pose_transform.cc @@ -800,7 +800,7 @@ static wmOperatorStatus pose_copy_exec(bContext *C, wmOperator *op) /* Sets chan->flag to POSE_KEY if bone selected. */ set_pose_keys(ob); - PartialWriteContext copybuffer{BKE_main_blendfile_path(bmain)}; + PartialWriteContext copybuffer{*bmain}; copybuffer.id_add( &ob->id, PartialWriteContext::IDAddOptions{ diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index ed4099b687e..0183b2d69e2 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -2718,7 +2718,7 @@ static wmOperatorStatus copy_material_exec(bContext *C, wmOperator *op) } Main *bmain = CTX_data_main(C); - PartialWriteContext copybuffer{BKE_main_blendfile_path(bmain)}; + PartialWriteContext copybuffer{*bmain}; /* Add the material to the copybuffer (and all of its dependencies). */ copybuffer.id_add( diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 4e55c96b080..2b3d85a3d32 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -839,7 +839,7 @@ static wmOperatorStatus outliner_id_copy_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - PartialWriteContext copybuffer{BKE_main_blendfile_path(bmain)}; + PartialWriteContext copybuffer{*bmain}; const int num_ids = outliner_id_copy_tag(space_outliner, &space_outliner->tree, copybuffer); if (num_ids == 0) { diff --git a/source/blender/editors/space_sequencer/sequencer_clipboard.cc b/source/blender/editors/space_sequencer/sequencer_clipboard.cc index d2ad2a4441e..db43f61130b 100644 --- a/source/blender/editors/space_sequencer/sequencer_clipboard.cc +++ b/source/blender/editors/space_sequencer/sequencer_clipboard.cc @@ -158,7 +158,7 @@ static bool sequencer_write_copy_paste_file(Main *bmain_src, /* NOTE: Setting the same current file path as G_MAIN is necessary for now to get correct * external filepaths when writing the partial write context on disk. otherwise, filepaths from * the scene's sequencer strips (e.g. image ones) would also need to be remapped in this code. */ - PartialWriteContext copy_buffer{bmain_src->filepath}; + PartialWriteContext copy_buffer{*bmain_src}; const char *scene_name = "copybuffer_vse_scene"; /* Add a dummy empty scene to the temporary Main copy buffer. */ diff --git a/source/blender/editors/space_view3d/view3d_ops.cc b/source/blender/editors/space_view3d/view3d_ops.cc index 15328590bb1..921db665faa 100644 --- a/source/blender/editors/space_view3d/view3d_ops.cc +++ b/source/blender/editors/space_view3d/view3d_ops.cc @@ -58,7 +58,7 @@ static wmOperatorStatus view3d_copybuffer_exec(bContext *C, wmOperator *op) using namespace blender::bke::blendfile; Main *bmain = CTX_data_main(C); - PartialWriteContext copybuffer{BKE_main_blendfile_path(bmain)}; + PartialWriteContext copybuffer{*bmain}; Object *obact = CTX_data_active_object(C); Object *obact_copy = nullptr; diff --git a/source/blender/python/intern/bpy_library_write.cc b/source/blender/python/intern/bpy_library_write.cc index 30848c0b0bb..4a142a29873 100644 --- a/source/blender/python/intern/bpy_library_write.cc +++ b/source/blender/python/intern/bpy_library_write.cc @@ -129,7 +129,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global()); - PartialWriteContext partial_write_ctx{bmain_src->filepath}; + PartialWriteContext partial_write_ctx{*bmain_src}; const PartialWriteContext::IDAddOptions add_options{ (PartialWriteContext::IDAddOperations::ADD_DEPENDENCIES | PartialWriteContext::IDAddOperations(