Blender  V3.3
wm_files_link.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2007 Blender Foundation. All rights reserved. */
3 
10 #include <ctype.h>
11 #include <errno.h>
12 #include <float.h>
13 #include <stddef.h>
14 #include <stdio.h>
15 #include <string.h>
16 
17 #include "CLG_log.h"
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "DNA_ID.h"
22 #include "DNA_collection_types.h"
23 #include "DNA_key_types.h"
24 #include "DNA_object_types.h"
25 #include "DNA_scene_types.h"
26 #include "DNA_screen_types.h"
28 
29 #include "BLI_bitmap.h"
30 #include "BLI_blenlib.h"
31 #include "BLI_ghash.h"
32 #include "BLI_linklist.h"
33 #include "BLI_math.h"
34 #include "BLI_memarena.h"
35 #include "BLI_utildefines.h"
36 
37 #include "BLO_readfile.h"
38 
39 #include "BKE_armature.h"
41 #include "BKE_context.h"
42 #include "BKE_global.h"
43 #include "BKE_key.h"
44 #include "BKE_layer.h"
45 #include "BKE_lib_id.h"
46 #include "BKE_lib_override.h"
47 #include "BKE_lib_query.h"
48 #include "BKE_lib_remap.h"
49 #include "BKE_main.h"
50 #include "BKE_material.h"
51 #include "BKE_object.h"
52 #include "BKE_report.h"
53 #include "BKE_rigidbody.h"
54 #include "BKE_scene.h"
55 
56 #include "BKE_idtype.h"
57 
58 #include "DEG_depsgraph.h"
59 #include "DEG_depsgraph_build.h"
60 
61 #include "IMB_colormanagement.h"
62 
63 #include "ED_datafiles.h"
64 #include "ED_screen.h"
65 
66 #include "RNA_access.h"
67 #include "RNA_define.h"
68 
69 #include "WM_api.h"
70 #include "WM_types.h"
71 
72 #include "wm_files.h"
73 
74 static CLG_LogRef LOG = {"wm.files_link"};
75 
76 /* -------------------------------------------------------------------- */
81 {
82  if (WM_operator_winactive(C)) {
83  /* linking changes active object which is pretty useful in general,
84  * but which totally confuses edit mode (i.e. it becoming not so obvious
85  * to leave from edit mode and invalid tools in toolbar might be displayed)
86  * so disable link/append when in edit mode (sergey) */
87  if (CTX_data_edit_object(C)) {
88  return 0;
89  }
90 
91  return 1;
92  }
93 
94  return 0;
95 }
96 
97 static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
98 {
99  if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
100  const char *blendfile_path = BKE_main_blendfile_path_from_global();
101  if (G.lib[0] != '\0') {
102  RNA_string_set(op->ptr, "filepath", G.lib);
103  }
104  else if (blendfile_path[0] != '\0') {
105  char path[FILE_MAX];
106  STRNCPY(path, blendfile_path);
107  BLI_path_parent_dir(path);
108  RNA_string_set(op->ptr, "filepath", path);
109  }
110  }
111 
113  return OPERATOR_RUNNING_MODAL;
114 }
115 
117 {
118  PropertyRNA *prop;
119  int flag = 0;
120 
121  if (RNA_boolean_get(op->ptr, "autoselect")) {
122  flag |= FILE_AUTOSELECT;
123  }
124  if (RNA_boolean_get(op->ptr, "active_collection")) {
125  flag |= FILE_ACTIVE_COLLECTION;
126  }
127  if ((prop = RNA_struct_find_property(op->ptr, "relative_path")) &&
128  RNA_property_boolean_get(op->ptr, prop)) {
129  flag |= FILE_RELPATH;
130  }
131  if (RNA_boolean_get(op->ptr, "link")) {
132  flag |= FILE_LINK;
133  }
134  else {
135  if (RNA_boolean_get(op->ptr, "use_recursive")) {
137  }
138  if (RNA_boolean_get(op->ptr, "set_fake")) {
140  }
141  if (RNA_boolean_get(op->ptr, "do_reuse_local_id")) {
143  }
144  }
145  if (RNA_boolean_get(op->ptr, "instance_collections")) {
147  }
148  if (RNA_boolean_get(op->ptr, "instance_object_data")) {
150  }
151 
152  return flag;
153 }
154 
161  const char *path,
162  const char *group,
163  const char *name,
164  const bool do_append)
165 {
166  short idcode;
167 
168  if (!group || !name) {
169  CLOG_WARN(&LOG, "Skipping %s", path);
170  return false;
171  }
172 
173  idcode = BKE_idtype_idcode_from_name(group);
174 
175  if (!BKE_idtype_idcode_is_linkable(idcode) ||
176  (!do_append && BKE_idtype_idcode_is_only_appendable(idcode))) {
177  if (reports) {
178  if (do_append) {
179  BKE_reportf(reports,
181  "Can't append data-block '%s' of type '%s'",
182  name,
183  group);
184  }
185  else {
186  BKE_reportf(reports,
188  "Can't link data-block '%s' of type '%s'",
189  name,
190  group);
191  }
192  }
193  return false;
194  }
195 
196  return true;
197 }
198 
200 {
201  Main *bmain = CTX_data_main(C);
203  ViewLayer *view_layer = CTX_data_view_layer(C);
204  PropertyRNA *prop;
205  BlendfileLinkAppendContext *lapp_context;
206  char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX_LIBEXTRA], relname[FILE_MAX];
207  char *group, *name;
208  int totfiles = 0;
209 
210  RNA_string_get(op->ptr, "filename", relname);
211  RNA_string_get(op->ptr, "directory", root);
212 
213  BLI_join_dirfile(path, sizeof(path), root, relname);
214 
215  /* test if we have a valid data */
216  if (!BLO_library_path_explode(path, libname, &group, &name)) {
217  BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", path);
218  return OPERATOR_CANCELLED;
219  }
220  if (!group) {
221  BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
222  return OPERATOR_CANCELLED;
223  }
224  if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
225  BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path);
226  return OPERATOR_CANCELLED;
227  }
228 
229  /* check if something is indicated for append/link */
230  prop = RNA_struct_find_property(op->ptr, "files");
231  if (prop) {
232  totfiles = RNA_property_collection_length(op->ptr, prop);
233  if (totfiles == 0) {
234  if (!name) {
235  BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
236  return OPERATOR_CANCELLED;
237  }
238  }
239  }
240  else if (!name) {
241  BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
242  return OPERATOR_CANCELLED;
243  }
244 
245  int flag = wm_link_append_flag(op);
246  const bool do_append = (flag & FILE_LINK) == 0;
247 
248  /* sanity checks for flag */
249  if (scene && scene->id.lib) {
250  BKE_reportf(op->reports,
251  RPT_WARNING,
252  "Scene '%s' is linked, instantiation of objects is disabled",
253  scene->id.name + 2);
255  scene = NULL;
256  }
257 
258  /* from here down, no error returns */
259 
260  if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) {
262  }
263 
264  /* tag everything, all untagged data can be made local
265  * its also generally useful to know what is new
266  *
267  * take extra care BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, false) is called after! */
269 
270  /* We define our working data...
271  * Note that here, each item 'uses' one library, and only one. */
272  LibraryLink_Params lapp_params;
274  &lapp_params, bmain, flag, 0, scene, view_layer, CTX_wm_view3d(C));
275 
276  lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
279 
280  if (totfiles != 0) {
282  int lib_idx = 0;
283 
284  RNA_BEGIN (op->ptr, itemptr, "files") {
285  RNA_string_get(&itemptr, "name", relname);
286 
287  BLI_join_dirfile(path, sizeof(path), root, relname);
288 
289  if (BLO_library_path_explode(path, libname, &group, &name)) {
290  if (!wm_link_append_item_poll(NULL, path, group, name, do_append)) {
291  continue;
292  }
293 
294  if (!BLI_ghash_haskey(libraries, libname)) {
295  BLI_ghash_insert(libraries, BLI_strdup(libname), POINTER_FROM_INT(lib_idx));
296  lib_idx++;
297  BKE_blendfile_link_append_context_library_add(lapp_context, libname, NULL);
298  }
299  }
300  }
301  RNA_END;
302 
303  RNA_BEGIN (op->ptr, itemptr, "files") {
304  RNA_string_get(&itemptr, "name", relname);
305 
306  BLI_join_dirfile(path, sizeof(path), root, relname);
307 
308  if (BLO_library_path_explode(path, libname, &group, &name)) {
310 
311  if (!wm_link_append_item_poll(op->reports, path, group, name, do_append)) {
312  continue;
313  }
314 
315  lib_idx = POINTER_AS_INT(BLI_ghash_lookup(libraries, libname));
316 
318  lapp_context, name, BKE_idtype_idcode_from_name(group), NULL);
320  }
321  }
322  RNA_END;
323 
324  BLI_ghash_free(libraries, MEM_freeN, NULL);
325  }
326  else {
328 
329  BKE_blendfile_link_append_context_library_add(lapp_context, libname, NULL);
331  lapp_context, name, BKE_idtype_idcode_from_name(group), NULL);
333  }
334 
335  if (BKE_blendfile_link_append_context_is_empty(lapp_context)) {
336  /* Early out in case there is nothing to link. */
338  /* Clear pre existing tag. */
340  return OPERATOR_CANCELLED;
341  }
342 
343  /* XXX We'd need re-entrant locking on Main for this to work... */
344  // BKE_main_lock(bmain);
345 
346  BKE_blendfile_link(lapp_context, op->reports);
347 
348  // BKE_main_unlock(bmain);
349 
350  /* mark all library linked objects to be updated */
353 
354  /* append, rather than linking */
355  if (do_append) {
356  BKE_blendfile_append(lapp_context, op->reports);
357  }
358 
360 
361  /* important we unset, otherwise these object won't
362  * link into other scenes from this blend file */
364 
365  /* TODO(sergey): Use proper flag for tagging here. */
366 
367  /* TODO(dalai): Temporary solution!
368  * Ideally we only need to tag the new objects themselves, not the scene.
369  * This way we'll avoid flush of collection properties
370  * to all objects and limit update to the particular object only.
371  * But afraid first we need to change collection evaluation in DEG
372  * according to depsgraph manifesto. */
373  DEG_id_tag_update(&scene->id, 0);
374 
375  /* recreate dependency graph to include new objects */
377 
378  /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
379  BLI_strncpy(G.lib, root, FILE_MAX);
380 
382 
383  return OPERATOR_FINISHED;
384 }
385 
387 {
388  PropertyRNA *prop;
389 
390  /* better not save _any_ settings for this operator */
391  /* properties */
392  prop = RNA_def_boolean(
393  ot->srna, "link", is_link, "Link", "Link the objects or data-blocks rather than appending");
395 
396  prop = RNA_def_boolean(
397  ot->srna,
398  "do_reuse_local_id",
399  false,
400  "Re-Use Local Data",
401  "Try to re-use previously matching appended data-blocks instead of appending a new copy");
403 
404  prop = RNA_def_boolean(ot->srna, "autoselect", true, "Select", "Select new objects");
406 
407  prop = RNA_def_boolean(ot->srna,
408  "active_collection",
409  true,
410  "Active Collection",
411  "Put new objects on the active collection");
413 
414  prop = RNA_def_boolean(
415  ot->srna,
416  "instance_collections",
417  is_link,
418  "Instance Collections",
419  "Create instances for collections, rather than adding them directly to the scene");
421 
422  prop = RNA_def_boolean(
423  ot->srna,
424  "instance_object_data",
425  true,
426  "Instance Object Data",
427  "Create instances for object data which are not referenced by any objects");
429 }
430 
432 {
433  ot->name = "Link";
434  ot->idname = "WM_OT_link";
435  ot->description = "Link from a Library .blend file";
436 
440 
441  ot->flag = OPTYPE_UNDO;
442 
445  FILE_LOADLIB,
451 
453 }
454 
456 {
457  ot->name = "Append";
458  ot->idname = "WM_OT_append";
459  ot->description = "Append from a Library .blend file";
460 
464 
465  ot->flag = OPTYPE_UNDO;
466 
469  FILE_LOADLIB,
475 
478  "set_fake",
479  false,
480  "Fake User",
481  "Set \"Fake User\" for appended items (except objects and collections)");
483  ot->srna,
484  "use_recursive",
485  true,
486  "Localize All",
487  "Localize all appended data, including those indirectly linked from other libraries");
488 }
489 
492 /* -------------------------------------------------------------------- */
498  Scene *scene,
499  ViewLayer *view_layer,
500  View3D *v3d,
501  const char *filepath,
502  const short id_code,
503  const char *id_name,
504  const int flag)
505 {
506  const bool do_append = (flag & FILE_LINK) == 0;
507  /* Tag everything so we can make local only the new datablock. */
509 
510  /* Define working data, with just the one item we want to link. */
511  LibraryLink_Params lapp_params;
512  BLO_library_link_params_init_with_context(&lapp_params, bmain, flag, 0, scene, view_layer, v3d);
513 
517 
518  BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
520  lapp_context, id_name, id_code, NULL);
522 
523  /* Link datablock. */
524  BKE_blendfile_link(lapp_context, NULL);
525 
526  if (do_append) {
527  BKE_blendfile_append(lapp_context, NULL);
528  }
529 
530  /* Get linked datablock and free working data. */
531  ID *id = BKE_blendfile_link_append_context_item_newid_get(lapp_context, item);
532 
534 
536 
537  return id;
538 }
539 
541  Scene *scene,
542  ViewLayer *view_layer,
543  View3D *v3d,
544  const char *filepath,
545  const short id_code,
546  const char *id_name,
547  int flag)
548 {
549  flag |= FILE_LINK;
551  bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag);
552 }
553 
555  Scene *scene,
556  ViewLayer *view_layer,
557  View3D *v3d,
558  const char *filepath,
559  const short id_code,
560  const char *id_name,
561  int flag)
562 {
563  BLI_assert((flag & FILE_LINK) == 0);
565  bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag);
566 
567  return id;
568 }
569 
572 /* -------------------------------------------------------------------- */
576 static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
577 {
578  Library *lib;
579  char lib_name[MAX_NAME];
580 
581  RNA_string_get(op->ptr, "library", lib_name);
583 
584  if (lib) {
585  if (lib->parent) {
586  BKE_reportf(op->reports,
588  "Cannot relocate indirectly linked library '%s'",
589  lib->filepath_abs);
590  return OPERATOR_CANCELLED;
591  }
592  RNA_string_set(op->ptr, "filepath", lib->filepath_abs);
593 
595 
596  return OPERATOR_RUNNING_MODAL;
597  }
598 
599  return OPERATOR_CANCELLED;
600 }
601 
603 {
604  if (!BLO_has_bfile_extension(lib->filepath_abs)) {
605  BKE_reportf(reports, RPT_ERROR, "'%s' is not a valid library filepath", lib->filepath_abs);
606  return;
607  }
608 
609  if (!BLI_exists(lib->filepath_abs)) {
610  BKE_reportf(reports,
611  RPT_ERROR,
612  "Trying to reload library '%s' from invalid path '%s'",
613  lib->id.name,
614  lib->filepath_abs);
615  return;
616  }
617 
618  Main *bmain = CTX_data_main(C);
619  LibraryLink_Params lapp_params;
621  bmain,
624  0,
625  CTX_data_scene(C),
627  NULL);
628 
630 
631  BKE_blendfile_link_append_context_library_add(lapp_context, lib->filepath_abs, NULL);
632 
633  BKE_blendfile_library_relocate(lapp_context, reports, lib, true);
634 
636 
639 
640  /* Important we unset, otherwise these object won't link into other scenes from this blend file.
641  */
643 
644  /* Recreate dependency graph to include new IDs. */
646 
648 }
649 
650 static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
651 {
652  Library *lib;
653  char lib_name[MAX_NAME];
654 
655  RNA_string_get(op->ptr, "library", lib_name);
657 
658  if (lib) {
659  Main *bmain = CTX_data_main(C);
660  PropertyRNA *prop;
661  BlendfileLinkAppendContext *lapp_context;
662 
663  char path[FILE_MAX], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX];
664  short flag = 0;
665 
666  if (RNA_boolean_get(op->ptr, "relative_path")) {
667  flag |= FILE_RELPATH;
668  }
669 
670  if (lib->parent && !do_reload) {
671  BKE_reportf(op->reports,
673  "Cannot relocate indirectly linked library '%s'",
674  lib->filepath_abs);
675  return OPERATOR_CANCELLED;
676  }
677 
678  RNA_string_get(op->ptr, "directory", root);
679  RNA_string_get(op->ptr, "filename", libname);
680 
681  if (!BLO_has_bfile_extension(libname)) {
682  BKE_report(op->reports, RPT_ERROR, "Not a library");
683  return OPERATOR_CANCELLED;
684  }
685 
686  BLI_join_dirfile(path, sizeof(path), root, libname);
687 
688  if (!BLI_exists(path)) {
689  BKE_reportf(op->reports,
691  "Trying to reload or relocate library '%s' to invalid path '%s'",
692  lib->id.name,
693  path);
694  return OPERATOR_CANCELLED;
695  }
696 
697  if (BLI_path_cmp(BKE_main_blendfile_path(bmain), path) == 0) {
698  BKE_reportf(op->reports,
700  "Cannot relocate library '%s' to current blend file '%s'",
701  lib->id.name,
702  path);
703  return OPERATOR_CANCELLED;
704  }
705 
706  LibraryLink_Params lapp_params;
708  &lapp_params, bmain, flag, 0, CTX_data_scene(C), CTX_data_view_layer(C), NULL);
709 
710  if (BLI_path_cmp(lib->filepath_abs, path) == 0) {
711  CLOG_INFO(&LOG, 4, "We are supposed to reload '%s' lib (%d)", lib->filepath, lib->id.us);
712 
713  do_reload = true;
714 
715  lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
717  }
718  else {
719  int totfiles = 0;
720 
721  CLOG_INFO(
722  &LOG, 4, "We are supposed to relocate '%s' lib to new '%s' one", lib->filepath, libname);
723 
724  /* Check if something is indicated for relocate. */
725  prop = RNA_struct_find_property(op->ptr, "files");
726  if (prop) {
727  totfiles = RNA_property_collection_length(op->ptr, prop);
728  if (totfiles == 0) {
729  if (!libname[0]) {
730  BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
731  return OPERATOR_CANCELLED;
732  }
733  }
734  }
735 
736  lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
737 
738  if (totfiles) {
739  RNA_BEGIN (op->ptr, itemptr, "files") {
740  RNA_string_get(&itemptr, "name", relname);
741 
742  BLI_join_dirfile(path, sizeof(path), root, relname);
743 
744  if (BLI_path_cmp(path, lib->filepath_abs) == 0 || !BLO_has_bfile_extension(relname)) {
745  continue;
746  }
747 
748  CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", path);
750  }
751  RNA_END;
752  }
753  else {
754  CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", path);
756  }
757  }
758 
761  (do_reload ? BLO_LIBLINK_USE_PLACEHOLDERS : 0),
762  true);
763 
764  BKE_blendfile_library_relocate(lapp_context, op->reports, lib, do_reload);
765 
767 
768  /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
769  BLI_strncpy(G.lib, root, FILE_MAX);
770 
773 
774  /* Important we unset, otherwise these object won't link into other scenes from this blend
775  * file.
776  */
778 
779  /* Recreate dependency graph to include new IDs. */
781 
783 
784  return OPERATOR_FINISHED;
785  }
786 
787  return OPERATOR_CANCELLED;
788 }
789 
791 {
792  return wm_lib_relocate_exec_do(C, op, false);
793 }
794 
796 {
797  PropertyRNA *prop;
798 
799  ot->name = "Relocate Library";
800  ot->idname = "WM_OT_lib_relocate";
801  ot->description = "Relocate the given library to one or several others";
802 
805 
806  ot->flag = OPTYPE_UNDO;
807 
808  prop = RNA_def_string(ot->srna, "library", NULL, MAX_NAME, "Library", "Library to relocate");
810 
813  FILE_BLENDER,
819 }
820 
822 {
823  return wm_lib_relocate_exec_do(C, op, true);
824 }
825 
827 {
828  PropertyRNA *prop;
829 
830  ot->name = "Reload Library";
831  ot->idname = "WM_OT_lib_reload";
832  ot->description = "Reload the given library";
833 
835 
836  ot->flag = OPTYPE_UNDO;
837 
838  prop = RNA_def_string(ot->srna, "library", NULL, MAX_NAME, "Library", "Library to reload");
840 
843  FILE_BLENDER,
849 }
850 
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
bool BKE_idtype_idcode_is_linkable(short idcode)
Definition: idtype.c:175
short BKE_idtype_idcode_from_name(const char *idtype_name)
Definition: idtype.c:163
bool BKE_idtype_idcode_is_only_appendable(short idcode)
Definition: idtype.c:182
void BKE_view_layer_base_deselect_all(struct ViewLayer *view_layer)
Definition: layer.c:388
void BKE_main_id_tag_all(struct Main *mainvar, int tag, bool value)
Definition: lib_id.c:930
void BKE_main_lib_objects_recalc_all(struct Main *bmain)
Definition: lib_id.c:998
struct ID * BKE_libblock_find_name(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: lib_id.c:1297
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
const char * BKE_main_blendfile_path_from_global(void)
Definition: main.c:562
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
API for Blender-side Rigid Body stuff.
#define BLI_assert(a)
Definition: BLI_assert.h:46
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:314
bool BLI_ghashutil_strcmp(const void *a, const void *b)
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:822
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:689
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
#define FILE_MAX
bool BLI_path_parent_dir(char *path) ATTR_NONNULL()
Definition: path_util.c:623
#define FILE_MAXDIR
#define BLI_path_cmp
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1531
#define STRNCPY(dst, src)
Definition: BLI_string.h:483
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
#define POINTER_FROM_INT(i)
#define UNUSED(x)
#define POINTER_AS_INT(i)
external readfile function prototypes.
@ BLO_LIBLINK_APPEND_RECURSIVE
Definition: BLO_readfile.h:339
@ BLO_LIBLINK_USE_PLACEHOLDERS
Definition: BLO_readfile.h:331
@ BLO_LIBLINK_OBDATA_INSTANCE
Definition: BLO_readfile.h:345
@ BLO_LIBLINK_APPEND_SET_FAKEUSER
Definition: BLO_readfile.h:335
@ BLO_LIBLINK_FORCE_INDIRECT
Definition: BLO_readfile.h:333
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
Definition: BLO_readfile.h:341
@ BLO_LIBLINK_COLLECTION_INSTANCE
Definition: BLO_readfile.h:347
void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, struct Main *bmain, int flag, int id_tag_extra, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d)
Definition: readfile.c:4633
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
Definition: readfile.c:1503
bool BLO_has_bfile_extension(const char *str)
Definition: readfile.c:1497
#define CLOG_WARN(clg_ref,...)
Definition: CLG_log.h:189
#define CLOG_INFO(clg_ref, level,...)
Definition: CLG_log.h:187
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
ID and Library types, which are fundamental for sdna.
@ LIB_TAG_PRE_EXISTING
Definition: DNA_ID.h:709
@ ID_LI
Definition: DNA_ID_enums.h:46
Object groups, one object can be in many groups at once.
#define MAX_NAME
Definition: DNA_defs.h:48
Object is a sort of wrapper for general info.
@ FILE_SORT_DEFAULT
@ FILE_LOADLIB
@ FILE_BLENDER
@ FILE_TYPE_BLENDER
@ FILE_TYPE_FOLDER
@ FILE_TYPE_BLENDERLIB
@ FILE_DEFAULTDISPLAY
@ FILE_ACTIVE_COLLECTION
@ FILE_RELPATH
@ FILE_AUTOSELECT
@ FILE_LINK
#define FILE_MAX_LIBEXTRA
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ RPT_ERROR_INVALID_INPUT
int datatoc_startup_blend_size
const char datatoc_startup_blend[]
void IMB_colormanagement_check_file_config(struct Main *bmain)
Read Guarded memory(de)allocation.
#define RNA_BEGIN(sptr, itemptr, propname)
Definition: RNA_access.h:543
#define RNA_END
Definition: RNA_access.h:550
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
@ WM_FILESEL_FILES
Definition: WM_api.h:756
@ WM_FILESEL_DIRECTORY
Definition: WM_api.h:753
@ WM_FILESEL_RELPATH
Definition: WM_api.h:752
@ WM_FILESEL_SHOW_PROPS
Definition: WM_api.h:758
@ WM_FILESEL_FILEPATH
Definition: WM_api.h:755
@ WM_FILESEL_FILENAME
Definition: WM_api.h:754
@ FILE_OPENFILE
Definition: WM_api.h:764
@ OPTYPE_UNDO
Definition: WM_types.h:148
#define NC_WINDOW
Definition: WM_types.h:325
std::string id_name(void *id)
Scene scene
DRWShaderLibrary * lib
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
#define G(x, y, z)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:5155
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2153
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:5301
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3762
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
Definition: DNA_ID.h:368
struct Library * lib
Definition: DNA_ID.h:372
char name[66]
Definition: DNA_ID.h:378
Definition: BKE_main.h:121
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct PointerRNA * ptr
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
bool WM_operator_winactive(bContext *C)