Skip to content

Commit

Permalink
Merge pull request #2846 from Autodesk/degiroa/MAYA-127428/missing-me…
Browse files Browse the repository at this point in the history
…tadata-notification

MAYA-127428 - Missing metadata notification.
  • Loading branch information
seando-adsk authored Feb 16, 2023
2 parents b383417 + d45ae66 commit 687ec05
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/mayaUsd/ufe/StagesSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#include <atomic>
#include <limits>
#include <regex>
#include <vector>

#ifdef UFE_V2_FEATURES_AVAILABLE
Expand Down Expand Up @@ -284,6 +285,25 @@ void attributeMetadataChanged(
sendAttributeMetadataChanged(ufePath, changedToken, changeType, metadataKeys);
}
}

std::vector<std::string> getMetadataKeys(const std::string& strMetadata)
{
std::vector<std::string> 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;
}
#endif

void processAttributeChanges(
Expand Down Expand Up @@ -321,12 +341,14 @@ void processAttributeChanges(
sendMetadataChanged = true;
std::stringstream newMetadataStream;
newMetadataStream << infoChanged.second.second;
std::string newMetadataKey = newMetadataStream.str();
if (!newMetadataKey.empty()) {
const std::string strMetadata = newMetadataStream.str();
// e.g. strMetadata string format:
// "'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0"
if (!strMetadata.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 : getMetadataKeys(strMetadata)) {
metadataKeys.insert(newMetadataKey);
}
}
}
}
Expand Down

0 comments on commit 687ec05

Please sign in to comment.