PythonSettings: Don't leak running watchers

Detected by memory analyzer.
When shutdown comes while pythonsFromRegistry() or
pythonsFromPath() is still running, the corresponding
QFutureWatcher is leaked.

Employ TaskTreeRunner instead. It handles the cancellation
of the running tasks automatically on its destruction.

Make pythonsFromRegistry() and pythonsFromPath() cancelable,
by providing QPromise as a parameter and check for canceled
state on every iteration.

Change-Id: Iae7c7d1ed764646b8203bd7ca8b9580cb999b80c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Jarek Kobus
2024-02-15 17:59:57 +01:00
parent e3b62d0aa5
commit d95fa019d4
2 changed files with 43 additions and 41 deletions

View File

@@ -5,6 +5,8 @@
#include <projectexplorer/runconfigurationaspects.h>
#include <solutions/tasking/tasktreerunner.h>
#include <utils/filepath.h>
namespace Python::Internal {
@@ -69,6 +71,7 @@ private:
QString m_defaultInterpreterId;
bool m_pylsEnabled = true;
QString m_pylsConfiguration;
Tasking::TaskTreeRunner m_taskTreeRunner;
static void saveSettings();
};