web: Destroy shouldn't be able to throw exceptions
This commit is contained in:
parent
58cd1abcf2
commit
69d1e903fb
|
@ -126,11 +126,7 @@ exports.RufflePlayer = class RufflePlayer extends HTMLElement {
|
|||
*/
|
||||
async ensure_fresh_instance() {
|
||||
if (this.instance) {
|
||||
try {
|
||||
this.instance.destroy();
|
||||
} catch (e) {
|
||||
console.warn("Error destroying old ruffle player:", e);
|
||||
}
|
||||
this.instance.destroy();
|
||||
this.instance = null;
|
||||
console.log("Ruffle instance destroyed.");
|
||||
}
|
||||
|
@ -313,14 +309,7 @@ exports.RufflePlayer = class RufflePlayer extends HTMLElement {
|
|||
*/
|
||||
panic() {
|
||||
if (this.instance) {
|
||||
try {
|
||||
this.instance.destroy();
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"Whilst panicking ruffle, an additional error was encountered during destruction:",
|
||||
e
|
||||
);
|
||||
}
|
||||
this.instance.destroy();
|
||||
this.instance = null;
|
||||
}
|
||||
// Clears out any existing content (ie play button or canvas) and replaces it with the error screen
|
||||
|
|
|
@ -152,7 +152,7 @@ impl Ruffle {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn destroy(&mut self) -> Result<(), JsValue> {
|
||||
pub fn destroy(&mut self) {
|
||||
// Remove instance from the active list.
|
||||
if let Some(instance) = INSTANCES.with(|instances| {
|
||||
let mut instances = instances.borrow_mut();
|
||||
|
@ -175,13 +175,12 @@ impl Ruffle {
|
|||
// Cancel the animation handler, if it's still active.
|
||||
if let Some(id) = instance.animation_handler_id {
|
||||
if let Some(window) = web_sys::window() {
|
||||
return window.cancel_animation_frame(id.into());
|
||||
let _ = window.cancel_animation_frame(id.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player is dropped at this point.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::boxed_local)] // for js_bind
|
||||
|
|
Loading…
Reference in New Issue