Blender V5.3
ed_id_management.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "CLG_log.h"
10
11#include "DNA_ID.h"
12
13#include "BKE_lib_id.hh"
14#include "BKE_library.hh"
15#include "BKE_main.hh"
16
17#include "WM_api.hh"
18
19#include "ED_id_management.hh"
20
21namespace blender {
22
24static CLG_LogRef LOG = {"lib.id_management"};
25
26bool ED_id_rename(Main &bmain, ID &id, StringRefNull name)
27{
29
32
33 switch (result.action) {
35 CLOG_DEBUG(&LOG, "ID '%s' not renamed, already using the requested name", id.name + 2);
36 return false;
39 "ID '%s' not renamed, requested new name '%s' would collide with an existing one",
40 id.name + 2,
41 name.c_str());
42 return false;
44 CLOG_DEBUG(&LOG, "ID '%s' renamed without any collision", id.name + 2);
46 return true;
49 "ID '%s' renamed with adjustment from requested name '%s', to avoid name "
50 "collision with another ID",
51 id.name + 2,
52 name.c_str());
54 "Data-block renamed to '%s', try again to force renaming it to '%s'",
55 id.name + 2,
56 name.c_str());
58 return true;
61 &LOG,
62 "ID '%s' forcefully renamed, another ID had to also be renamed to avoid name collision",
63 id.name + 2);
65 "Name in use. The other data-block was renamed to '%s'",
66 result.other_id->name + 2);
69 return true;
70 }
71
72 return false;
73}
74
75} // namespace blender
#define CLOG_DEBUG(clg_ref,...)
Definition CLG_log.h:191
ID and Library types, which are fundamental for SDNA.
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define NC_ID
Definition WM_types.hh:408
#define NA_RENAME
Definition WM_types.hh:638
constexpr const char * c_str() const
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_global_reportf(eReportType type, const char *format,...)
bool ED_id_rename(Main &bmain, ID &id, StringRefNull name)
static CLG_LogRef LOG
Definition logging.cpp:12
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2654