Blender V4.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
9#include "MEM_guardedalloc.h"
10
11#include "CLG_log.h"
12
13#include "DNA_ID.h"
14
15#include "BKE_lib_id.hh"
16#include "BKE_main.hh"
17
18#include "WM_api.hh"
19
20#include "ED_id_management.hh"
21
23static CLG_LogRef LOG = {"ed.id_management"};
24
26{
28
29 const IDNewNameResult result = BKE_id_rename(
31
32 switch (result.action) {
34 CLOG_INFO(&LOG, 4, "ID '%s' not renamed, already using the requested name", id.name + 2);
35 return false;
38 4,
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_INFO(&LOG, 4, "ID '%s' renamed without any collision", id.name + 2);
45 return true;
48 4,
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());
57 return true;
60 &LOG,
61 4,
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);
67 return true;
68 }
69
70 return false;
71}
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2338
#define BLI_assert(a)
Definition BLI_assert.h:50
#define CLOG_INFO(clg_ref, level,...)
Definition CLG_log.h:179
ID and Library types, which are fundamental for SDNA.
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:658
Read Guarded memory(de)allocation.
bool ED_id_rename(Main &bmain, ID &id, blender::StringRefNull name)
static CLG_LogRef LOG
Definition DNA_ID.h:413
void WM_reportf(eReportType type, const char *format,...)