mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Support returning errors when creating the app (#4565)
The closure passed to `eframe::run_native` now returns a `Result`, allowing you to return an error during app creation, which will be returned to the caller of `run_native`. This means you need to wrap your `Box::new(MyApp::new(…))` in an `Ok(…)`. * Closes https://github.com/emilk/egui/issues/4474
This commit is contained in:
@@ -41,10 +41,12 @@ pub type EventLoopBuilderHook = Box<dyn FnOnce(&mut EventLoopBuilder<UserEvent>)
|
||||
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||
pub type WindowBuilderHook = Box<dyn FnOnce(egui::ViewportBuilder) -> egui::ViewportBuilder>;
|
||||
|
||||
type DynError = Box<dyn std::error::Error>;
|
||||
|
||||
/// This is how your app is created.
|
||||
///
|
||||
/// You can use the [`CreationContext`] to setup egui, restore state, setup OpenGL things, etc.
|
||||
pub type AppCreator = Box<dyn FnOnce(&CreationContext<'_>) -> Box<dyn App>>;
|
||||
pub type AppCreator = Box<dyn FnOnce(&CreationContext<'_>) -> Result<Box<dyn App>, DynError>>;
|
||||
|
||||
/// Data that is passed to [`AppCreator`] that can be used to setup and initialize your app.
|
||||
pub struct CreationContext<'s> {
|
||||
|
||||
Reference in New Issue
Block a user