Fix #146448: Object copy/paste has wrong colors with working space
Write proper colorspace information into copy buffer blend files. Pull Request: https://projects.blender.org/blender/blender/pulls/146450
This commit is contained in:
committed by
Brecht Van Lommel
parent
fdd8d85f89
commit
bb57ab3598
@@ -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();
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,7 +160,7 @@ static bool asset_write_in_library(Main &bmain,
|
||||
|
||||
ID &id = const_cast<ID &>(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 |
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user