mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
eframe error handling (#2433)
* eframe::run_native: return errors instead of crashing * Detect and handle glutin errors * egui_demo_app: silence wgpu log spam * Add trace logs for why eframe is shutting down * Fix: only save App state once on Mac * Handle Winit failure * Log where we load app state from * Don't panic on zero-sized window * Clamp loaded window size to not be too tiny to see * Simplify code: more shared code in window_builder * Improve code readability * Fix wasm32 build * fix android * Update changelog
This commit is contained in:
@@ -46,12 +46,13 @@ impl WindowSettings {
|
||||
&self,
|
||||
mut window: winit::window::WindowBuilder,
|
||||
) -> winit::window::WindowBuilder {
|
||||
if !cfg!(target_os = "windows") {
|
||||
// If the app last ran on two monitors and only one is now connected, then
|
||||
// the given position is invalid.
|
||||
// If this happens on Mac, the window is clamped into valid area.
|
||||
// If this happens on Windows, the window is hidden and very difficult to find.
|
||||
// So we don't restore window positions on Windows.
|
||||
// If the app last ran on two monitors and only one is now connected, then
|
||||
// the given position is invalid.
|
||||
// If this happens on Mac, the window is clamped into valid area.
|
||||
// If this happens on Windows, the window is hidden and very difficult to find.
|
||||
// So we don't restore window positions on Windows.
|
||||
let try_restore_position = !cfg!(target_os = "windows");
|
||||
if try_restore_position {
|
||||
if let Some(pos) = self.position {
|
||||
window = window.with_position(winit::dpi::PhysicalPosition {
|
||||
x: pos.x as f64,
|
||||
@@ -74,4 +75,12 @@ impl WindowSettings {
|
||||
window
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clamp_to_sane_values(&mut self) {
|
||||
if let Some(size) = &mut self.inner_size_points {
|
||||
// Prevent ridiculously small windows
|
||||
let min_size = egui::Vec2::splat(64.0);
|
||||
*size = size.max(min_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user