From 42f7ba8ab6c8fa6873985117796aae4d9b457980 Mon Sep 17 00:00:00 2001 From: alicedegirolamo Date: Thu, 26 Jan 2023 15:23:50 +0100 Subject: [PATCH 1/4] MAYA-127428 - Missing metadata notification. --- lib/mayaUsd/ufe/StagesSubject.cpp | 13 ++++++++----- lib/mayaUsd/ufe/Utils.cpp | 24 ++++++++++++++++++++++++ lib/mayaUsd/ufe/Utils.h | 7 +++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lib/mayaUsd/ufe/StagesSubject.cpp b/lib/mayaUsd/ufe/StagesSubject.cpp index 9073e3f066..fd9adc3d51 100644 --- a/lib/mayaUsd/ufe/StagesSubject.cpp +++ b/lib/mayaUsd/ufe/StagesSubject.cpp @@ -321,12 +321,15 @@ void processAttributeChanges( sendMetadataChanged = true; std::stringstream newMetadataStream; newMetadataStream << infoChanged.second.second; - std::string newMetadataKey = newMetadataStream.str(); - if (!newMetadataKey.empty()) { + std::string newMetadataKeys = newMetadataStream.str(); + // e.g. newMetadataKeys string format: + // "'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0" + if (!newMetadataKeys.empty()) { // Find the modified key which is between a pair of single quotes. - newMetadataKey = newMetadataKey.substr( - newMetadataKey.find('\'') + 1, newMetadataKey.rfind('\'') - 2); - metadataKeys.insert(newMetadataKey); + for (const auto& newMetadataKey : + MayaUsd::ufe::getSubStrings(newMetadataKeys, "'", "':")) { + metadataKeys.insert(newMetadataKey); + } } } } diff --git a/lib/mayaUsd/ufe/Utils.cpp b/lib/mayaUsd/ufe/Utils.cpp index 43c1b95283..a17270107b 100644 --- a/lib/mayaUsd/ufe/Utils.cpp +++ b/lib/mayaUsd/ufe/Utils.cpp @@ -1185,6 +1185,30 @@ std::vector splitString(const std::string& str, const std::string& return split; } +std::vector getSubStrings( + const std::string& str, + const std::string& startSeparator, + const std::string& endSeparator) +{ + std::vector subStrings; + const std::string rgxString = "(" + startSeparator + ")" + "([^ ]*)" + "(" + endSeparator + ")"; + const std::regex rgx(rgxString); + std::string subString; + + for (std::sregex_iterator it(str.begin(), str.end(), rgx), it_end; it != it_end; ++it) { + if (it->empty()) { + continue; + } + subString = std::string((*it)[0]); + // Remove the separators. + subString = subString.substr( + subString.find(startSeparator.back()) + 1, subString.rfind(endSeparator.front()) - 1); + subStrings.push_back(subString); + } + + return subStrings; +} + #ifdef MAYA_HAS_DISPLAY_LAYER_API template void handleDisplayLayer( diff --git a/lib/mayaUsd/ufe/Utils.h b/lib/mayaUsd/ufe/Utils.h index f7a3f50e8d..fd527004fe 100644 --- a/lib/mayaUsd/ufe/Utils.h +++ b/lib/mayaUsd/ufe/Utils.h @@ -216,6 +216,13 @@ Ufe::Selection recreateDescendants(const Ufe::Selection& src, const Ufe::Path& f MAYAUSD_CORE_PUBLIC std::vector splitString(const std::string& str, const std::string& separators); +//! Gets the sub strings surrounded by separators. +MAYAUSD_CORE_PUBLIC +std::vector getSubStrings( + const std::string& str, + const std::string& startSeparator, + const std::string& endSeparator); + std::string pathSegmentSeparator(); class ReplicateExtrasFromUSD From e2118e896367cda5cf081c36c42f1bc6a3bde181 Mon Sep 17 00:00:00 2001 From: alicedegirolamo Date: Fri, 27 Jan 2023 18:58:26 +0100 Subject: [PATCH 2/4] MAYA-127428 - PR Changes --- lib/mayaUsd/ufe/StagesSubject.cpp | 25 ++++++++++++++++++++++--- lib/mayaUsd/ufe/Utils.cpp | 24 ------------------------ lib/mayaUsd/ufe/Utils.h | 7 ------- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/lib/mayaUsd/ufe/StagesSubject.cpp b/lib/mayaUsd/ufe/StagesSubject.cpp index fd9adc3d51..bc76029db5 100644 --- a/lib/mayaUsd/ufe/StagesSubject.cpp +++ b/lib/mayaUsd/ufe/StagesSubject.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #ifdef UFE_V2_FEATURES_AVAILABLE @@ -286,6 +287,25 @@ void attributeMetadataChanged( } #endif +std::vector getMetadataKeys(const std::string& strMetadata) +{ + std::vector metadataKeys; + const std::regex rgx("(')([^ ]*)(':)"); + std::string metadataKey; + + for (std::sregex_iterator it(strMetadata.begin(), strMetadata.end(), rgx), it_end; it != it_end; + ++it) { + if (it->empty()) { + continue; + } + metadataKey = std::string((*it)[0]); + metadataKey = metadataKey.substr(metadataKey.find('\'') + 1, metadataKey.rfind('\'') - 1); + metadataKeys.push_back(metadataKey); + } + + return metadataKeys; +} + void processAttributeChanges( const Ufe::Path& ufePath, const SdfPath& changedPath, @@ -321,13 +341,12 @@ void processAttributeChanges( sendMetadataChanged = true; std::stringstream newMetadataStream; newMetadataStream << infoChanged.second.second; - std::string newMetadataKeys = newMetadataStream.str(); + const std::string newMetadataKeys = newMetadataStream.str(); // e.g. newMetadataKeys string format: // "'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0" if (!newMetadataKeys.empty()) { // Find the modified key which is between a pair of single quotes. - for (const auto& newMetadataKey : - MayaUsd::ufe::getSubStrings(newMetadataKeys, "'", "':")) { + for (const auto& newMetadataKey : getMetadataKeys(newMetadataKeys)) { metadataKeys.insert(newMetadataKey); } } diff --git a/lib/mayaUsd/ufe/Utils.cpp b/lib/mayaUsd/ufe/Utils.cpp index a17270107b..43c1b95283 100644 --- a/lib/mayaUsd/ufe/Utils.cpp +++ b/lib/mayaUsd/ufe/Utils.cpp @@ -1185,30 +1185,6 @@ std::vector splitString(const std::string& str, const std::string& return split; } -std::vector getSubStrings( - const std::string& str, - const std::string& startSeparator, - const std::string& endSeparator) -{ - std::vector subStrings; - const std::string rgxString = "(" + startSeparator + ")" + "([^ ]*)" + "(" + endSeparator + ")"; - const std::regex rgx(rgxString); - std::string subString; - - for (std::sregex_iterator it(str.begin(), str.end(), rgx), it_end; it != it_end; ++it) { - if (it->empty()) { - continue; - } - subString = std::string((*it)[0]); - // Remove the separators. - subString = subString.substr( - subString.find(startSeparator.back()) + 1, subString.rfind(endSeparator.front()) - 1); - subStrings.push_back(subString); - } - - return subStrings; -} - #ifdef MAYA_HAS_DISPLAY_LAYER_API template void handleDisplayLayer( diff --git a/lib/mayaUsd/ufe/Utils.h b/lib/mayaUsd/ufe/Utils.h index fd527004fe..f7a3f50e8d 100644 --- a/lib/mayaUsd/ufe/Utils.h +++ b/lib/mayaUsd/ufe/Utils.h @@ -216,13 +216,6 @@ Ufe::Selection recreateDescendants(const Ufe::Selection& src, const Ufe::Path& f MAYAUSD_CORE_PUBLIC std::vector splitString(const std::string& str, const std::string& separators); -//! Gets the sub strings surrounded by separators. -MAYAUSD_CORE_PUBLIC -std::vector getSubStrings( - const std::string& str, - const std::string& startSeparator, - const std::string& endSeparator); - std::string pathSegmentSeparator(); class ReplicateExtrasFromUSD From 2be22ac2754b3b290b63e02f9e712d50d08ddbc4 Mon Sep 17 00:00:00 2001 From: alicedegirolamo Date: Fri, 27 Jan 2023 19:12:31 +0100 Subject: [PATCH 3/4] MAYA-127428 - PR Change - var renaming --- lib/mayaUsd/ufe/StagesSubject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mayaUsd/ufe/StagesSubject.cpp b/lib/mayaUsd/ufe/StagesSubject.cpp index bc76029db5..c5276d97d4 100644 --- a/lib/mayaUsd/ufe/StagesSubject.cpp +++ b/lib/mayaUsd/ufe/StagesSubject.cpp @@ -341,12 +341,12 @@ void processAttributeChanges( sendMetadataChanged = true; std::stringstream newMetadataStream; newMetadataStream << infoChanged.second.second; - const std::string newMetadataKeys = newMetadataStream.str(); - // e.g. newMetadataKeys string format: + const std::string strMetadata = newMetadataStream.str(); + // e.g. strMetadata string format: // "'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0" - if (!newMetadataKeys.empty()) { + if (!strMetadata.empty()) { // Find the modified key which is between a pair of single quotes. - for (const auto& newMetadataKey : getMetadataKeys(newMetadataKeys)) { + for (const auto& newMetadataKey : getMetadataKeys(strMetadata)) { metadataKeys.insert(newMetadataKey); } } From d45ae66ae24e795eac5354c68d472af3307e1ec3 Mon Sep 17 00:00:00 2001 From: alicedegirolamo Date: Tue, 31 Jan 2023 10:46:40 +0100 Subject: [PATCH 4/4] MAYA-127428 Fix for build failure on Linux and OS/X platforms --- lib/mayaUsd/ufe/StagesSubject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/ufe/StagesSubject.cpp b/lib/mayaUsd/ufe/StagesSubject.cpp index c5276d97d4..1b3b0d82ce 100644 --- a/lib/mayaUsd/ufe/StagesSubject.cpp +++ b/lib/mayaUsd/ufe/StagesSubject.cpp @@ -285,7 +285,6 @@ void attributeMetadataChanged( sendAttributeMetadataChanged(ufePath, changedToken, changeType, metadataKeys); } } -#endif std::vector getMetadataKeys(const std::string& strMetadata) { @@ -305,6 +304,7 @@ std::vector getMetadataKeys(const std::string& strMetadata) return metadataKeys; } +#endif void processAttributeChanges( const Ufe::Path& ufePath,