From e7e90cd0db6b4c6e4a8cbcfaf345c6600ed9905b Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Sat, 27 Apr 2024 12:28:04 +0200 Subject: [PATCH] Add missing panic check in drop impl All other `panic!`s in drop implementation check first if the thread is already panicking. Signed-off-by: Jonathan Schwender --- surfman/src/renderbuffers.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/surfman/src/renderbuffers.rs b/surfman/src/renderbuffers.rs index f83d2136..515313bb 100644 --- a/surfman/src/renderbuffers.rs +++ b/surfman/src/renderbuffers.rs @@ -6,6 +6,7 @@ use crate::context::{ContextAttributeFlags, ContextAttributes}; use crate::gl; use crate::gl::types::GLuint; use crate::Gl; +use std::thread; use euclid::default::Size2D; @@ -22,7 +23,11 @@ impl Drop for Renderbuffers { stencil: 0, } | Renderbuffers::CombinedDepthStencil(0) => {} - _ => panic!("Should have destroyed the FBO renderbuffers with `destroy()`!"), + _ => { + if !thread::panicking() { + panic!("Should have destroyed the FBO renderbuffers with `destroy()`!") + } + } } } }