Skip to content

Commit 7eb3d4f

Browse files
committed
- Do not use config proxy for absolute paths while computing file hash or loading LUT data. - Added the unit test provided in the ticket. Signed-off-by: cuneyt.ozdas <[email protected]>
1 parent 6fa40a4 commit 7eb3d4f

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/OpenColorIO/PathUtils.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ std::string GetFastFileHash(const std::string & filename, const Context & contex
8888
fileHashResultPtr->ready = true;
8989

9090
std::string h = "";
91-
if (!context.getConfigIOProxy())
91+
if (!pystring::os::path::isabs(filename) && context.getConfigIOProxy())
9292
{
93-
// Default case.
94-
h = g_hashFunction(filename);
93+
// Case for when ConfigIOProxy is used (callbacks mechanism).
94+
h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str());
9595
}
9696
else
9797
{
98-
// Case for when ConfigIOProxy is used (callbacks mechanism).
99-
h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str());
98+
// Default case
99+
h = g_hashFunction(filename);
100100
}
101101

102102
fileHashResultPtr->hash = h;
103103
}
104-
104+
105105
hash = fileHashResultPtr->hash;
106106
}
107107

src/OpenColorIO/transforms/FileTransform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ std::unique_ptr<std::istream> getLutData(
190190
const std::string & filepath,
191191
std::ios_base::openmode mode)
192192
{
193-
if (config.getConfigIOProxy())
193+
if (!pystring::os::path::isabs(filepath) && config.getConfigIOProxy())
194194
{
195195
std::vector<uint8_t> buffer = config.getConfigIOProxy()->getLutData(filepath.c_str());
196196
std::stringstream ss;

tests/cpu/OCIOZArchive_tests.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,18 @@ OCIO_ADD_TEST(OCIOZArchive, context_test_for_search_paths_and_filetransform_sour
331331

332332
auto testPaths = [&mat](const OCIO::ConfigRcPtr & cfg, const OCIO::ContextRcPtr ctx)
333333
{
334+
{
335+
const std::string filePath = OCIO::GetTestFilesDir() + "/matrix_example4x4.ctf";
336+
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
337+
transform->setSrc(filePath.c_str());
338+
OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(transform);
339+
OCIO::ConstTransformRcPtr tr = processor->createGroupTransform()->getTransform(0);
340+
auto mtx = OCIO::DynamicPtrCast<const OCIO::MatrixTransform>(tr);
341+
OCIO_REQUIRE_ASSERT(mtx);
342+
mtx->getMatrix(mat);
343+
OCIO_CHECK_EQUAL(mat[0], 3.24);
344+
}
345+
334346
{
335347
// This is independent of the context.
336348
OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(ctx, "shot1_lut1_cs", "reference");

0 commit comments

Comments
 (0)