From 8f6fe913d1e7df4f65b023b5a9670167772869fc Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Mon, 24 Sep 2018 15:21:28 +0200
Subject: [PATCH] Cleaner shutdown
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The print-job manager was trying to recreate a notification service, so
destroy it earlier, and at the same time kill the content runner before
existing WebEngineContext::destroy() to catch any other late
recreations of singletons.

Change-Id: Ifaa333386248c3dbc6d4f828c727a0a17d5f5c90
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
---
 src/core/web_engine_context.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 8408ff708..7cd7d485b 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -223,6 +223,11 @@ void WebEngineContext::destroy()
     // Flush the UI message loop before quitting.
     while (delegate->DoWork()) { }
 
+#if QT_CONFIG(webengine_printing_and_pdf)
+    // Kill print job manager early as it has a content::NotificationRegistrar
+    m_printJobManager.reset();
+#endif
+
     // Delete the global object and thus custom profiles
     m_defaultProfileAdapter.reset();
     m_globalQObject.reset();
@@ -241,6 +246,10 @@ void WebEngineContext::destroy()
     // default BrowserContext might be used by the RenderprocessHostImpl's destructor.
     m_browserRunner.reset();
 
+    // Destroying content-runner will force Chromium at_exit calls to run, and
+    // reap child processes.
+    m_contentRunner.reset();
+
     // Drop the false reference.
     m_handle->Release();
 }
-- 
GitLab