8000 Make `Memory::keep_popup_open` less of a footgun by lucasmerlin · Pull Request #7297 · emilk/egui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make Memory::keep_popup_open less of a footgun #7297

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucasmerlin
Copy link
Collaborator

The breaking change is intentional, to force people to think about this, since otherwise the keep_popup_open thing would silently break popups.

@lucasmerlin lucasmerlin added feature New feature or request egui labels Jul 3, 2025
Copy link
github-actions bot commented Jul 3, 2025

Preview available at https://egui-pr-preview.github.io/pr/7297-lucaspopup-footgun
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

self.popups
.get(&self.viewport_id)
.is_some_and(|state| state.id == popup_id)
|| self.everything_is_visible()
}

/// Check if the popup is open and keep it open. 8000
pub fn show_popup(&mut self, popup_id: Id) -> bool {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring for open_popup should link to this function, and vice-versa, to explain their difference..

Also: wouldn't it make sense if this called self.open_popup?

Copy link
Collaborator Author
@lucasmerlin lucasmerlin Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if this called open_popup, you couldn't use it to check if we should show the popup.

The docs should also mention it needs to be called every frame.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just another shape of footgun.

Based only on the names of the functions, I would expect this to always hold:

mem.show_popup(popup_id);
assert!(mem.is_showing_popup(popup_id));

Which would then lead to the question "what is open_popup for?"

@@ -531,7 +531,7 @@ impl<'a> Popup<'a> {
mem.toggle_popup(id);
}
None => {
mem.keep_popup_open(id);
mem.show_popup(id);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we always call this unless we return None below? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Memory::keep_popup_open less of a footgun
2 participants
0