Fix segfault caused by improper drop order
@@ -26,7 +26,7 @@ use crate::id::QuerySetId;
use crate::resource::QuerySet;
#[cfg(debug_assertions)]
use std::cell::Cell;
-use std::{fmt::Debug, marker::PhantomData, ops, thread};
+use std::{fmt::Debug, marker::PhantomData, ops};
/// A simple structure to manage identities of objects.
#[derive(Debug)]
@@ -783,12 +783,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
fn drop(&mut self) {
- if !thread::panicking() {
profiling::scope!("drop", "Global");
log::info!("Dropping Global");
let mut surface_guard = self.surfaces.data.write();
- // destroy hubs
+ // destroy hubs before the instance gets dropped
#[cfg(vulkan)]
{
self.hubs.vulkan.clear(&mut *surface_guard, true);
@@ -818,7 +817,6 @@ impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
}
}
}
-}
pub trait GfxBackend: hal::Backend {
const VARIANT: Backend;
