Skip to content

Commit 5cf3bfd

Browse files
authored
Merge pull request #99 from dalance/fix_panic_in_drop
Fix panic in drop
2 parents ba598d6 + 999011b commit 5cf3bfd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/drawing/backend_impl/bitmap.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ impl<'a, P: PixelFormat> DrawingBackend for BitMapBackend<'a, P> {
998998
impl<P: PixelFormat> Drop for BitMapBackend<'_, P> {
999999
fn drop(&mut self) {
10001000
if !self.saved {
1001-
self.present().expect("Unable to save the bitmap");
1001+
// drop should not panic, so we ignore a failed present
1002+
let _ = self.present();
10021003
}
10031004
}
10041005
}

src/drawing/backend_impl/svg.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
565565
impl Drop for SVGBackend<'_> {
566566
fn drop(&mut self) {
567567
if !self.saved {
568-
self.present().expect("Unable to save the SVG image");
568+
// drop should not panic, so we ignore a failed present
569+
let _ = self.present();
569570
}
570571
}
571572
}

0 commit comments

Comments
 (0)