Skip to content
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

When an immediate viewport is displayed, the cache will return None. #5441

Open
zhatuokun opened this issue Dec 6, 2024 · 0 comments
Open
Labels
bug Something is broken

Comments

@zhatuokun
Copy link
Contributor

Describe the bug
Cache works well in general, but when you have an immediate viewport, it will return None.

To Reproduce
Steps to reproduce the behavior:

  1. add master branch to Cargo.toml.
egui = { git = "https://github.com/emilk/egui", branch = "master" }
eframe = { git = "https://github.com/emilk/egui", branch = "master" }
  1. run this code.
type MyPublisher = egui::cache::FramePublisher<String, u32>;

fn main() -> eframe::Result {
    eframe::run_simple_native("Example", eframe::NativeOptions::default(), |ctx, _| {
        let key = String::from("key");
        let value = ctx.memory_mut(|m| m.caches.cache::<MyPublisher>().get(&key).copied());
        println!("value: {value:?}");
        ctx.memory_mut(|m| m.caches.cache::<MyPublisher>().set(key, 0));

        // If I comment out the following code, everything will be fine.
        ctx.show_viewport_immediate(
            egui::ViewportId::from_hash_of("ExampleViewport"),
            Default::default(),
            |_, _| {},
        );
    })
}

Expected behavior
Even if immediate viewport is displayed, the cache should work properly.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: 23H2
@zhatuokun zhatuokun added the bug Something is broken label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant