Skip to content

Make Memory::keep_popup_open less of a footgun#7297

Closed
lucasmerlin wants to merge 2 commits intomainfrom
lucas/popup-footgun
Closed

Make Memory::keep_popup_open less of a footgun#7297
lucasmerlin wants to merge 2 commits intomainfrom
lucas/popup-footgun

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
@github-actions
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.

}

/// Check if the popup is open and keep it open.
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?"

}
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? 🤔

@emilk emilk marked this pull request as draft July 9, 2025 08:51
@emilk
Copy link
Owner

emilk commented Jul 9, 2025

I'm doing another take on this

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