Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-05-17 16:29:24 +0300
committerBastien Montagne <bastien@blender.org>2022-05-17 17:06:54 +0300
commit939c2387a158722cafa84fc09f0eb13b67c603fe (patch)
tree621a65462ed853c09a858b59b695c5444e9afaf1 /source/blender/blenloader
parentb759a3eac0d6506d2e81075d1e663bc34d4d3401 (diff)
Cleanup: blendloader: add logger to `writefile.c`, remove some asserts.
Properly use CLOG to report info or errors in `writefile.c`, instead of printf's. And remove some assert when logging error reports and the issue is not critical.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/blenloader/intern/writefile.c32
2 files changed, 20 insertions, 13 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 1b9c450967a..973965ada50 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -477,7 +477,6 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li
}
else {
CLOG_ERROR(&LOG, "Invalid library for '%s'", id->name);
- BLI_assert(0);
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index b0a25221098..080ec50e0fb 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -73,6 +73,8 @@
#include "BLI_utildefines.h"
+#include "CLG_log.h"
+
/* allow writefile to use deprecated functionality (for forward compatibility code) */
#define DNA_DEPRECATED_ALLOW
@@ -133,6 +135,8 @@
#define ZSTD_COMPRESSION_LEVEL 3
+static CLG_LogRef LOG = {"blo.writefile"};
+
/** Use if we want to store how many bytes have been written to the file. */
// #define USE_WRITE_DATA_LEN
@@ -973,7 +977,7 @@ static void write_libraries(WriteData *wd, Main *main)
if (main->curlib->packedfile) {
BKE_packedfile_blend_write(&writer, main->curlib->packedfile);
if (wd->use_memfile == false) {
- printf("write packed .blend: %s\n", main->curlib->filepath);
+ CLOG_INFO(&LOG, 2, "Write packed .blend: %s\n", main->curlib->filepath);
}
}
@@ -984,12 +988,11 @@ static void write_libraries(WriteData *wd, Main *main)
((id->tag & LIB_TAG_EXTERN) ||
((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) {
if (!BKE_idtype_idcode_is_linkable(GS(id->name))) {
- printf(
- "ERROR: write file: data-block '%s' from lib '%s' is not linkable "
- "but is flagged as directly linked\n",
- id->name,
- main->curlib->filepath_abs);
- BLI_assert(0);
+ CLOG_ERROR(&LOG,
+ "Data-block '%s' from lib '%s' is not linkable, but is flagged as "
+ "directly linked\n",
+ id->name,
+ main->curlib->filepath_abs);
}
writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id);
}
@@ -1129,9 +1132,15 @@ static bool write_file_handle(Main *mainvar,
char id_buffer_static[ID_BUFFER_STATIC_SIZE];
void *id_buffer = id_buffer_static;
- const size_t idtype_struct_size = BKE_idtype_get_info_from_id(id)->struct_size;
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ const size_t idtype_struct_size = id_type->struct_size;
if (idtype_struct_size > ID_BUFFER_STATIC_SIZE) {
- BLI_assert(0);
+ CLOG_ERROR(&LOG,
+ "ID maximum buffer size (%d bytes) is not big enough to fit IDs of type %s, "
+ "which needs %lu bytes",
+ ID_BUFFER_STATIC_SIZE,
+ id_type->name,
+ id_type->struct_size);
id_buffer = MEM_mallocN(idtype_struct_size, __func__);
}
@@ -1200,7 +1209,6 @@ static bool write_file_handle(Main *mainvar,
* #direct_link_id_common in `readfile.c` anyway, */
((ID *)id_buffer)->py_instance = NULL;
- const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
if (id_type->blend_write != NULL) {
id_type->blend_write(&writer, (ID *)id_buffer, id);
}
@@ -1482,7 +1490,7 @@ void BLO_write_struct_array_by_name(BlendWriter *writer,
{
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
if (UNLIKELY(struct_id == -1)) {
- printf("error: can't find SDNA code <%s>\n", struct_name);
+ CLOG_ERROR(&LOG, "Can't find SDNA code <%s>\n", struct_name);
return;
}
BLO_write_struct_array_by_id(writer, struct_id, array_size, data_ptr);
@@ -1530,7 +1538,7 @@ void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name,
{
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
if (UNLIKELY(struct_id == -1)) {
- printf("error: can't find SDNA code <%s>\n", struct_name);
+ CLOG_ERROR(&LOG, "Can't find SDNA code <%s>\n", struct_name);
return;
}
BLO_write_struct_list_by_id(writer, struct_id, list);