[Bf-blender-cvs] [89757f918cf] master: Revert "Fix T86026: Crash Opening Cryptomatte File."
Jeroen Bakker
noreply at git.blender.org
Mon Mar 8 08:53:02 CET 2021
Commit: 89757f918cfa9e087f1a55f7c94688a1f623b612
Author: Jeroen Bakker
Date: Mon Mar 8 08:28:31 2021 +0100
Branches: master
https://developer.blender.org/rB89757f918cfa9e087f1a55f7c94688a1f623b612
Revert "Fix T86026: Crash Opening Cryptomatte File."
This reverts commit 7f3649874070de38131263317d02906d50279f93.
===================================================================
M source/blender/blenkernel/intern/cryptomatte.cc
M source/blender/blenkernel/intern/cryptomatte_test.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc
index 9d9cace3a35..3188656aa6b 100644
--- a/source/blender/blenkernel/intern/cryptomatte.cc
+++ b/source/blender/blenkernel/intern/cryptomatte.cc
@@ -184,30 +184,22 @@ float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
char *BKE_cryptomatte_entries_to_matte_id(NodeCryptomatte *node_storage)
{
- std::stringstream ss;
- ss.precision(9);
-
+ DynStr *matte_id = BLI_dynstr_new();
bool first = true;
LISTBASE_FOREACH (CryptomatteEntry *, entry, &node_storage->entries) {
if (!first) {
- ss << ',';
+ BLI_dynstr_append(matte_id, ",");
}
- blender::StringRef entry_name(entry->name, BLI_strnlen(entry->name, sizeof(entry->name)));
- if (!entry_name.is_empty()) {
- ss << entry_name;
+ if (BLI_strnlen(entry->name, sizeof(entry->name)) != 0) {
+ BLI_dynstr_nappend(matte_id, entry->name, sizeof(entry->name));
}
else {
- ss << '<' << std::scientific << entry->encoded_hash << '>';
+ BLI_dynstr_appendf(matte_id, "<%.9g>", entry->encoded_hash);
}
first = false;
}
-
- /* Convert result to C string. */
- const std::string result_string = ss.str();
- const char *c_str = result_string.c_str();
- size_t result_len = result_string.size() + 1;
- char *result = static_cast<char *>(MEM_mallocN(sizeof(char) * result_len, __func__));
- memcpy(result, c_str, result_len);
+ char *result = BLI_dynstr_get_cstring(matte_id);
+ BLI_dynstr_free(matte_id);
return result;
}
diff --git a/source/blender/blenkernel/intern/cryptomatte_test.cc b/source/blender/blenkernel/intern/cryptomatte_test.cc
index 22abd1a4d56..13e29cecf0a 100644
--- a/source/blender/blenkernel/intern/cryptomatte_test.cc
+++ b/source/blender/blenkernel/intern/cryptomatte_test.cc
@@ -21,8 +21,6 @@
#include "BKE_cryptomatte.hh"
#include "BKE_image.h"
-#include "DNA_node_types.h"
-
#include "RE_pipeline.h"
#include "MEM_guardedalloc.h"
@@ -176,15 +174,4 @@ TEST(cryptomatte, session_from_stamp_data)
BKE_cryptomatte_free(session);
}
-TEST(cryptomatte, T86026)
-{
- NodeCryptomatte storage = {{0.0f}};
- CryptomatteEntry entry = {nullptr};
- BLI_addtail(&storage.entries, &entry);
- entry.encoded_hash = 4.76190593e-07;
- char *matte_id = BKE_cryptomatte_entries_to_matte_id(&storage);
- EXPECT_STREQ("<4.761905927e-07>", matte_id);
- MEM_freeN(matte_id);
-}
-
} // namespace blender::bke::cryptomatte::tests
More information about the Bf-blender-cvs
mailing list