From bad0c79f651d8bf3699911481191804d5df7ec7c Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 24 Sep 2021 23:23:22 +0100 Subject: [PATCH] Handling any events that were dispatched to the main thread event listener, during startup, before passing control of the main thread over to Insight. --- src/Application.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 2822b2b9..2262ea0d 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -49,8 +49,18 @@ int Application::run(const std::vector& arguments) { this->insight->setApplicationConfig(this->applicationConfig); this->insight->setEnvironmentConfig(this->environmentConfig); this->insight->setInsightConfig(this->insightConfig); - this->insight->run(); - Logger::debug("Insight closed"); + + /* + * Before letting Insight occupy the main thread, process any pending events that accumulated + * during startup. + */ + this->applicationEventListener->dispatchCurrentEvents(); + + if (Thread::getThreadState() == ThreadState::READY) { + this->insight->run(); + Logger::debug("Insight closed"); + } + this->shutdown(); return EXIT_SUCCESS; }