-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAYA-127428 - Missing metadata notification. #2846
MAYA-127428 - Missing metadata notification. #2846
Conversation
lib/mayaUsd/ufe/Utils.h
Outdated
@@ -216,6 +216,13 @@ Ufe::Selection recreateDescendants(const Ufe::Selection& src, const Ufe::Path& f | |||
MAYAUSD_CORE_PUBLIC | |||
std::vector<std::string> splitString(const std::string& str, const std::string& separators); | |||
|
|||
//! Gets the sub strings surrounded by separators. | |||
MAYAUSD_CORE_PUBLIC | |||
std::vector<std::string> getSubStrings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the name of this method makes it sound like this is a generic function, but it really seems kind of specific to the metadata stream, no? Do you think this method is generic enough to warrant it being in Utils.h, or should it just be a helper function in StagesSubject.cpp where it is being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Jonathan. The example string you give above "'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0"
is very metadata specific. I would move it like Jonathan suggests and also rename it with metadata in name.
lib/mayaUsd/ufe/StagesSubject.cpp
Outdated
@@ -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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can newMetadataKeys be const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for changes requested by Jonathan.
lib/mayaUsd/ufe/StagesSubject.cpp
Outdated
@@ -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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor) I'd probably rename this to strMetadata for consistency.
- var renaming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There is a build failure on Linux and OS/X platforms:
|
d45ae66
Thanks for looking in the build logs, now it should be fixed. |
std::vector<std::string> getMetadataKeys(const std::string& strMetadata) | ||
{ | ||
std::vector<std::string> metadataKeys; | ||
const std::regex rgx("(')([^ ]*)(':)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are using the power of regular expressions, but not to their full extent. Please read more about capture groups. The function can be rewritten as:
std::vector<std::string> getMetadataKeys(const std::string& strMetadata)
{
std::vector<std::string> metadataKeys;
const std::regex rgx("'([^ ]*)':");
for (std::sregex_iterator it(strMetadata.begin(), strMetadata.end(), rgx), it_end; it != it_end;
++it) {
metadataKeys.push_back(std::string((*it)[1]));
}
return metadataKeys;
}
And work exactly as requested by extracting the captured strings.
Description
This PR solves the issue described in Jira Ticket MAYA-127428
Type of change
We were parsing erroneously the string with all the metadata keys and values.
As an example, with the following metadata string:
"'uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder':0"
we got the list with the following string:
"uifolder':,'uisoftmin':0.0, 'uihide':1, 'uiorder"
With the proposed solution we get the populated list:
"uifolder","uisoftmin", "uihide", "uiorder"
which triggers the correct notification for the metadatas.