From 7eb3d4fa26ee1f7f5c745e01d837d83dc62226ef Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Thu, 9 Jan 2025 10:12:36 -0800 Subject: [PATCH] Ticket #2111 - 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 --- src/OpenColorIO/PathUtils.cpp | 12 ++++++------ src/OpenColorIO/transforms/FileTransform.cpp | 2 +- tests/cpu/OCIOZArchive_tests.cpp | 12 ++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/OpenColorIO/PathUtils.cpp b/src/OpenColorIO/PathUtils.cpp index bd9fb11351..709416aa64 100644 --- a/src/OpenColorIO/PathUtils.cpp +++ b/src/OpenColorIO/PathUtils.cpp @@ -88,20 +88,20 @@ std::string GetFastFileHash(const std::string & filename, const Context & contex fileHashResultPtr->ready = true; std::string h = ""; - if (!context.getConfigIOProxy()) + if (!pystring::os::path::isabs(filename) && context.getConfigIOProxy()) { - // Default case. - h = g_hashFunction(filename); + // Case for when ConfigIOProxy is used (callbacks mechanism). + h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str()); } else { - // Case for when ConfigIOProxy is used (callbacks mechanism). - h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str()); + // Default case + h = g_hashFunction(filename); } fileHashResultPtr->hash = h; } - + hash = fileHashResultPtr->hash; } diff --git a/src/OpenColorIO/transforms/FileTransform.cpp b/src/OpenColorIO/transforms/FileTransform.cpp index faf1d343e3..abcec4b924 100755 --- a/src/OpenColorIO/transforms/FileTransform.cpp +++ b/src/OpenColorIO/transforms/FileTransform.cpp @@ -190,7 +190,7 @@ std::unique_ptr getLutData( const std::string & filepath, std::ios_base::openmode mode) { - if (config.getConfigIOProxy()) + if (!pystring::os::path::isabs(filepath) && config.getConfigIOProxy()) { std::vector buffer = config.getConfigIOProxy()->getLutData(filepath.c_str()); std::stringstream ss; diff --git a/tests/cpu/OCIOZArchive_tests.cpp b/tests/cpu/OCIOZArchive_tests.cpp index 1f23550000..cd54911ad9 100644 --- a/tests/cpu/OCIOZArchive_tests.cpp +++ b/tests/cpu/OCIOZArchive_tests.cpp @@ -331,6 +331,18 @@ OCIO_ADD_TEST(OCIOZArchive, context_test_for_search_paths_and_filetransform_sour auto testPaths = [&mat](const OCIO::ConfigRcPtr & cfg, const OCIO::ContextRcPtr ctx) { + { + const std::string filePath = OCIO::GetTestFilesDir() + "/matrix_example4x4.ctf"; + OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); + transform->setSrc(filePath.c_str()); + OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(transform); + OCIO::ConstTransformRcPtr tr = processor->createGroupTransform()->getTransform(0); + auto mtx = OCIO::DynamicPtrCast(tr); + OCIO_REQUIRE_ASSERT(mtx); + mtx->getMatrix(mat); + OCIO_CHECK_EQUAL(mat[0], 3.24); + } + { // This is independent of the context. OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(ctx, "shot1_lut1_cs", "reference");