Fix panic when minimizing, show backtraces when panicking

Former-commit-id: 0ad401d81a2f7b4d0b766578238d2ab9259f80eb
This commit is contained in:
robojumper 2019-05-05 20:42:44 +02:00
parent 370ec5cbd6
commit 31a8e653c4
2 changed files with 10 additions and 2 deletions

View File

@ -99,6 +99,7 @@ fn main() {
// Set up panic handler to relay swish panic messages to the user
let settings_clone = settings.clone();
let default_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| {
let msg = format!(" \
A critical error has occured and Voxygen has been forced to terminate in an unusual manner. Details about the error can be found below.
@ -126,6 +127,8 @@ The information below is intended for developers and testers.
log::error!("VOXYGEN HAS PANICKED\n\n{}", msg);
msgbox::create("Voxygen has panicked", &msg, msgbox::IconType::ERROR);
default_hook(panic_info);
}));
let mut global_state = GlobalState { settings, window };

View File

@ -609,8 +609,13 @@ impl Ui {
self.scale.window_resized(new_dims, renderer);
let (w, h) = self.scale.scaled_window_size().into_tuple();
self.ui.handle_event(Input::Resize(w, h));
self.cache
.clear_graphic_cache(renderer, renderer.get_resolution().map(|e| e * 4));
let res = renderer.get_resolution();
// Avoid panic in graphic cache when minimizing
if res.x > 0 && res.y > 0 {
self.cache
.clear_graphic_cache(renderer, renderer.get_resolution().map(|e| e * 4));
}
// TODO: probably need to resize glyph cache, see conrod's gfx backend for reference
}
}