From 8e9bf1c2a9c22279fee205028350215d7d56944c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 Sep 2020 16:24:45 +0200 Subject: [PATCH] [libcalamaresui] Another allow-to-fall-back-to-eventloop With 1 CPU, Calamares still spawns 9 threads or so: eventloop, dbus loop, QML loop, ... many of those are invisible to the application. Contention occurs on startup when the UI is constructed, and we end up with the module manager creating widgets alongside, or ahead of, the main window UI. This can result in deadlock: - in CalamaresApplication::initViewSteps - in QML imports This is partly because the signal-slots connections get "deep": from loadModules() we emit *modulesLoaded* which ends up showing the main window in initViewSteps(). Avoid this with a QTimer: drop back to the event loop and release whatever locks are held, so the QML thread can get on with it already. Then the timer goes off and the view steps are created. --- src/libcalamaresui/modulesystem/ModuleManager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 102ca9308..d630e67f2 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -281,11 +281,13 @@ ModuleManager::loadModules() if ( !failedModules.isEmpty() ) { ViewManager::instance()->onInitFailed( failedModules ); - emit modulesFailed( failedModules ); + QTimer::singleShot( 10, [=]() { + emit modulesFailed( failedModules ); + } ); } else { - emit modulesLoaded(); + QTimer::singleShot( 10, this, &ModuleManager::modulesLoaded ); } }