Cleanup: Remove unused & deprecated BKE_copybuffer_copy_ and BKE_blendfile_write_partial_ APIs.
These have now been fully replaced by the `PartialWriteContext` API.
This commit is contained in:
@@ -14,24 +14,8 @@ struct Main;
|
||||
struct ReportList;
|
||||
struct bContext;
|
||||
|
||||
/* Copy-buffer (wrapper for BKE_blendfile_write_partial). */
|
||||
/** Paste-buffer helper API. For copy, use directly the #PartialWriteContext API. */
|
||||
|
||||
/**
|
||||
* Initialize a copy operation.
|
||||
*/
|
||||
void BKE_copybuffer_copy_begin(Main *bmain_src);
|
||||
/**
|
||||
* Mark an ID to be copied. Should only be called after a call to #BKE_copybuffer_copy_begin.
|
||||
*/
|
||||
void BKE_copybuffer_copy_tag_ID(ID *id);
|
||||
/**
|
||||
* Finalize a copy operation into given .blend file 'buffer'.
|
||||
*
|
||||
* \param filename: Full path to the .blend file used as copy/paste buffer.
|
||||
*
|
||||
* \return true on success, false otherwise.
|
||||
*/
|
||||
bool BKE_copybuffer_copy_end(Main *bmain_src, const char *filename, ReportList *reports);
|
||||
/**
|
||||
* Paste data-blocks from the given .blend file 'buffer' (i.e. append them).
|
||||
*
|
||||
|
||||
@@ -425,13 +425,3 @@ class PartialWriteContext : NonCopyable, NonMovable {
|
||||
};
|
||||
|
||||
} // namespace blender::bke::blendfile
|
||||
|
||||
void BKE_blendfile_write_partial_tag_ID(ID *id, bool set);
|
||||
void BKE_blendfile_write_partial_begin(Main *bmain_src);
|
||||
/**
|
||||
* \param remap_mode: Choose the kind of path remapping or none #eBLO_WritePathRemap.
|
||||
* \return Success.
|
||||
*/
|
||||
bool BKE_blendfile_write_partial(
|
||||
Main *bmain_src, const char *filepath, int write_flags, int remap_mode, ReportList *reports);
|
||||
void BKE_blendfile_write_partial_end(Main *bmain_src);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_blender_copybuffer.hh" /* own include */
|
||||
#include "BKE_blendfile.hh"
|
||||
#include "BKE_blendfile_link_append.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_layer.hh"
|
||||
@@ -31,31 +30,9 @@
|
||||
#include "IMB_colormanagement.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Copy/Paste `.blend`, partial saves.
|
||||
/** \name Paste API based on 'partial' blendfiles.
|
||||
* \{ */
|
||||
|
||||
void BKE_copybuffer_copy_begin(Main *bmain_src)
|
||||
{
|
||||
BKE_blendfile_write_partial_begin(bmain_src);
|
||||
}
|
||||
|
||||
void BKE_copybuffer_copy_tag_ID(ID *id)
|
||||
{
|
||||
BKE_blendfile_write_partial_tag_ID(id, true);
|
||||
}
|
||||
|
||||
bool BKE_copybuffer_copy_end(Main *bmain_src, const char *filename, ReportList *reports)
|
||||
{
|
||||
const int write_flags = 0;
|
||||
const eBLO_WritePathRemap remap_mode = BLO_WRITE_PATH_REMAP_RELATIVE;
|
||||
|
||||
bool retval = BKE_blendfile_write_partial(bmain_src, filename, write_flags, remap_mode, reports);
|
||||
|
||||
BKE_blendfile_write_partial_end(bmain_src);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Common helper for paste functions. */
|
||||
static void copybuffer_append(BlendfileLinkAppendContext *lapp_context,
|
||||
Main *bmain,
|
||||
|
||||
@@ -2133,128 +2133,4 @@ bool PartialWriteContext::write(const char *write_filepath, ReportList &reports)
|
||||
|
||||
} // namespace blender::bke::blendfile
|
||||
|
||||
static void blendfile_write_partial_clear_flags(Main *bmain_src)
|
||||
{
|
||||
ListBase *lbarray[INDEX_ID_MAX];
|
||||
int a = set_listbasepointers(bmain_src, lbarray);
|
||||
while (a--) {
|
||||
LISTBASE_FOREACH (ID *, id, lbarray[a]) {
|
||||
id->tag &= ~(LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT);
|
||||
id->flag &= ~(LIB_CLIPBOARD_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_blendfile_write_partial_begin(Main *bmain_src)
|
||||
{
|
||||
blendfile_write_partial_clear_flags(bmain_src);
|
||||
}
|
||||
|
||||
void BKE_blendfile_write_partial_tag_ID(ID *id, bool set)
|
||||
{
|
||||
if (set) {
|
||||
id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
|
||||
id->flag |= LIB_CLIPBOARD_MARK;
|
||||
}
|
||||
else {
|
||||
id->tag &= ~(LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT);
|
||||
id->flag &= ~LIB_CLIPBOARD_MARK;
|
||||
}
|
||||
}
|
||||
|
||||
static void blendfile_write_partial_cb(void * /*handle*/, Main * /*bmain*/, void *vid)
|
||||
{
|
||||
if (vid) {
|
||||
ID *id = static_cast<ID *>(vid);
|
||||
/* only tag for need-expand if not done, prevents eternal loops */
|
||||
if ((id->tag & LIB_TAG_DOIT) == 0) {
|
||||
id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
|
||||
}
|
||||
|
||||
if (id->lib && (id->lib->id.tag & LIB_TAG_DOIT) == 0) {
|
||||
id->lib->id.tag |= LIB_TAG_DOIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BKE_blendfile_write_partial(Main *bmain_src,
|
||||
const char *filepath,
|
||||
const int write_flags,
|
||||
const int remap_mode,
|
||||
ReportList *reports)
|
||||
{
|
||||
Main *bmain_dst = MEM_cnew<Main>("copybuffer");
|
||||
ListBase *lbarray_dst[INDEX_ID_MAX], *lbarray_src[INDEX_ID_MAX];
|
||||
int a, retval;
|
||||
|
||||
void *path_list_backup = nullptr;
|
||||
const eBPathForeachFlag path_list_flag = (BKE_BPATH_FOREACH_PATH_SKIP_LINKED |
|
||||
BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE);
|
||||
|
||||
/* This is needed to be able to load that file as a real one later
|
||||
* (otherwise `main->filepath` will not be set at read time). */
|
||||
STRNCPY(bmain_dst->filepath, bmain_src->filepath);
|
||||
|
||||
BLO_expand_main(nullptr, bmain_src, blendfile_write_partial_cb);
|
||||
|
||||
/* move over all tagged blocks */
|
||||
set_listbasepointers(bmain_src, lbarray_src);
|
||||
a = set_listbasepointers(bmain_dst, lbarray_dst);
|
||||
while (a--) {
|
||||
ID *id, *nextid;
|
||||
ListBase *lb_dst = lbarray_dst[a], *lb_src = lbarray_src[a];
|
||||
|
||||
for (id = static_cast<ID *>(lb_src->first); id; id = nextid) {
|
||||
nextid = static_cast<ID *>(id->next);
|
||||
if (id->tag & LIB_TAG_DOIT) {
|
||||
BLI_remlink(lb_src, id);
|
||||
BLI_addtail(lb_dst, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Backup paths because remap relative will overwrite them.
|
||||
*
|
||||
* NOTE: we do this only on the list of data-blocks that we are writing
|
||||
* because the restored full list is not guaranteed to be in the same
|
||||
* order as before, as expected by BKE_bpath_list_restore.
|
||||
*
|
||||
* This happens because id_sort_by_name does not take into account
|
||||
* string case or the library name, so the order is not strictly
|
||||
* defined for two linked data-blocks with the same name! */
|
||||
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
|
||||
path_list_backup = BKE_bpath_list_backup(bmain_dst, path_list_flag);
|
||||
}
|
||||
|
||||
/* save the buffer */
|
||||
BlendFileWriteParams blend_file_write_params{};
|
||||
blend_file_write_params.remap_mode = eBLO_WritePathRemap(remap_mode);
|
||||
retval = BLO_write_file(bmain_dst, filepath, write_flags, &blend_file_write_params, reports);
|
||||
|
||||
if (path_list_backup) {
|
||||
BKE_bpath_list_restore(bmain_dst, path_list_flag, path_list_backup);
|
||||
BKE_bpath_list_free(path_list_backup);
|
||||
}
|
||||
|
||||
/* move back the main, now sorted again */
|
||||
set_listbasepointers(bmain_src, lbarray_dst);
|
||||
a = set_listbasepointers(bmain_dst, lbarray_src);
|
||||
while (a--) {
|
||||
ListBase *lb_dst = lbarray_dst[a], *lb_src = lbarray_src[a];
|
||||
while (ID *id = static_cast<ID *>(BLI_pophead(lb_src))) {
|
||||
BLI_addtail(lb_dst, id);
|
||||
id_sort_by_name(lb_dst, id, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(bmain_dst);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void BKE_blendfile_write_partial_end(Main *bmain_src)
|
||||
{
|
||||
blendfile_write_partial_clear_flags(bmain_src);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
Reference in New Issue
Block a user