aboutsummaryrefslogtreecommitdiff
path: root/src/drawing/backend_impl/mocked.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/drawing/backend_impl/mocked.rs')
-rw-r--r--src/drawing/backend_impl/mocked.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/drawing/backend_impl/mocked.rs b/src/drawing/backend_impl/mocked.rs
index da6bfec..7569e73 100644
--- a/src/drawing/backend_impl/mocked.rs
+++ b/src/drawing/backend_impl/mocked.rs
@@ -269,6 +269,13 @@ impl DrawingBackend for MockedBackend {
impl Drop for MockedBackend {
fn drop(&mut self) {
+ // `self.drop_check` is typically a testing function; it can panic.
+ // The current `drop` call may be a part of stack unwinding caused
+ // by another panic. If so, we should never call it.
+ if std::thread::panicking() {
+ return;
+ }
+
let mut temp = None;
std::mem::swap(&mut temp, &mut self.drop_check);