From 99ee3763c1dae9c0dd7e28aa6fae0a2a79c7b1c1 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 17 May 2021 23:59:32 +0200 Subject: [PATCH] USBMS: Close all widgets before quitting FFI finalizers can fire in unspecified orders, but for MuPDF, we need to ensure that the context is the *very* last thing that get destroyed. As such, we need to make sure we close open documents properly on our end, first. This prevents potential crashes while switchign to USBMS inside an open document handled by MuPDF. Fix #7428 --- frontend/ui/elements/mass_storage.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/ui/elements/mass_storage.lua b/frontend/ui/elements/mass_storage.lua index b4948915f..32eae485f 100644 --- a/frontend/ui/elements/mass_storage.lua +++ b/frontend/ui/elements/mass_storage.lua @@ -1,4 +1,5 @@ local Device = require("device") +local Event = require("ui/event") local UIManager = require("ui/uimanager") local _ = require("gettext") @@ -60,15 +61,17 @@ function MassStorage:start(never_ask) ok_callback = function() -- save settings before activating USBMS: UIManager:flushSettings() - UIManager:quit() UIManager._exit_code = 86 + UIManager:broadcastEvent(Event:new("Close")) + UIManager:quit() end, }) else -- save settings before activating USBMS: UIManager:flushSettings() - UIManager:quit() UIManager._exit_code = 86 + UIManager:broadcastEvent(Event:new("Close")) + UIManager:quit() end end