I think the best solution is to retain quit_hook with its current
functionality (maybe renamed to something like quit_requested_hook)
and add a new hook, exiting_hook, which is called when conkeror is
definitely exiting and which can be used for cleanup operations. This
new hook would be suitable for the session auto save and, perhaps, for
the walnut summary. It would be called from an xpcom-shutdown
observer.

Something like the following should be enough. (Although I don't use sessions and haven't checked that it will work there.)

Subject: [PATCH] Add exiting_hook

This new hook is called when conkeror is exiting.  It is distinct from
quit_hook, which is called when the quit function is called to exit
conkeror.  The latter may be overridden by the daemon.
---
 modules/commands.js |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/modules/commands.js b/modules/commands.js
index 0f82e36..47e5a43 100644
--- a/modules/commands.js
+++ b/modules/commands.js
@@ -8,6 +8,14 @@
 **/

 define_hook("quit_hook");
+define_hook("exiting_hook");
+
+let exiting_observer = {
+    observe : function (subject, topic, data) {
+        exiting_hook.run();
+    }
+}
+observer_service.addObserver(exiting_observer, "xpcom-shutdown", false);

 function quit () {
     quit_hook.run();
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to