From ffa70b915d45272563a3db8edc1f4d1078cb9827 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Wed, 11 Jan 2023 10:39:35 +0100 Subject: [PATCH] start: Make start-browser synchronous. There is no point in having it asynchronous, since anything run in parallel before browser is ready is likely to trigger a race conditions or undefined behaviour. It simplifies testing a lot. --- source/browser.lisp | 6 ++++++ source/start.lisp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/browser.lisp b/source/browser.lisp index 48d4b0277f7c..9137f746f374 100644 --- a/source/browser.lisp +++ b/source/browser.lisp @@ -150,6 +150,11 @@ issued by Control+ in a new window.") (time:now) :export nil :documentation "`time:timestamp' of when Nyxt was started.") + (startup-promise + (lpara:promise) + :export nil + :accessor nil + :documentation "") (init-time 0.0 :type alex:non-negative-real @@ -390,6 +395,7 @@ restored." (error (c) ;; TODO: Clear buffers or back up history? (log:warn c))) + (lpara:fulfill (slot-value browser 'startup-promise)) (hooks:run-hook (after-startup-hook browser) browser) (funcall* (startup-error-reporter-function browser))))) diff --git a/source/start.lisp b/source/start.lisp index 987b34c0d5c4..3a7ef7bfed5d 100644 --- a/source/start.lisp +++ b/source/start.lisp @@ -584,7 +584,8 @@ Finally, run the browser, load URL-STRINGS if any, then run ;; is the case with the SLY mrepl thread. (bt:make-thread (lambda () (in-package :nyxt-user))) - (ffi-initialize *browser* urls startup-timestamp)))) + (ffi-initialize *browser* urls startup-timestamp) + (lpara:force (slot-value *browser* 'startup-promise))))) (quit () :report "Run `nyxt:quit' and try again." (quit)