-
Notifications
You must be signed in to change notification settings - Fork 102
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
RmlUI Context handling improvements #1761
base: master
Are you sure you want to change the base?
RmlUI Context handling improvements #1761
Conversation
* manage contexts in the "contexts_to_remove" hashset more carefully to prevent use-after-free crash. * Remove context from removal hashset if it is "recreated" in the same frame.
Rml::Context* context = Rml::GetContext(name); | ||
if (context == nullptr) { | ||
context = Rml::CreateContext(name, {0, 0}); | ||
} else if (state->contexts_to_remove.contains(context)) { |
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.
} else if (state->contexts_to_remove.contains(context)) { | |
} else if (state->contexts_to_remove.contains(context)) { | |
// can happen if name reused on the same frame |
if (context == nullptr) { | ||
context = Rml::CreateContext(name, {0, 0}); | ||
} else if (state->contexts_to_remove.contains(context)) { | ||
state->contexts_to_remove.erase(context); |
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.
Maybe we could do without the .contains
check? .erase
has to search for the element anyway so we'd avoid searching it twice if present and won't see any difference if not.
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 didn't realize I could do that
context handling improvements
use ranges::rotate to reorder clicked context