From 61b78d88953f01ec0933c50f21a6fb92df16446a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 7 Jun 2019 11:46:08 +0200 Subject: [PATCH] [libcalamares] Stop job threads before exit - This solves a crash where the thread is destroyed while still running (e.g. cancelling during install). - The thread might not cooperate in being terminated, but then we have a bigger problem anyway (and Calamares will still crash on exit). FIXES #1164 --- src/libcalamares/JobQueue.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 6ef055ffc..3a76aa099 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -44,7 +44,7 @@ public: } virtual ~JobThread() override; - + void setJobs( const JobList& jobs ) { m_jobs = jobs; @@ -157,6 +157,14 @@ JobQueue::JobQueue( QObject* parent ) JobQueue::~JobQueue() { + if ( m_thread->isRunning() ) + { + m_thread->terminate(); + if ( !m_thread->wait(300) ) + cError() << "Could not terminate job thread (expect a crash now)."; + delete m_thread; + } + delete m_storage; }