aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cpptypehierarchy.h
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-12-08 09:27:38 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-12-10 12:44:49 +0000
commit82b2735da40a8146100307afe628e775d96afcc2 (patch)
tree8f140e9aaa48799283e2861374efa79898efca75 /src/plugins/cppeditor/cpptypehierarchy.h
parentf440dfe43a286ef1d84d4fe1e281ea8996e64148 (diff)
Don't leak memory when canceling Type Hierarchy
Add QFutureSynchronizer for collecting all running futures (including those already canceled, but not finished yet). It could happen, that we cancel the future, while the associated task still needs some time in order to catch the cancel request. When a d'tor of synchronizer is run it cancels and waits for all pending futures to be finished. Add extra check for isCanceled() after a call to updateDependencyTable(). In case the cancel was detected inside updateDependencyTable(), we should return immediately. Don't leak CppClass object inside handleLookupItemMatch() when the task was canceled. Amends: c400923308f5c4df4e8d96a04d12dc54322f7ade Change-Id: I709e14a0c8b563d522a8e8c32b087e5f83310b24 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cpptypehierarchy.h')
-rw-r--r--src/plugins/cppeditor/cpptypehierarchy.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cpptypehierarchy.h b/src/plugins/cppeditor/cpptypehierarchy.h
index 83b1a4d99f..94414db895 100644
--- a/src/plugins/cppeditor/cpptypehierarchy.h
+++ b/src/plugins/cppeditor/cpptypehierarchy.h
@@ -29,6 +29,7 @@
#include <QFuture>
#include <QFutureWatcher>
+#include <QFutureSynchronizer>
#include <QList>
#include <QSharedPointer>
#include <QStackedWidget>
@@ -75,7 +76,6 @@ class CppTypeHierarchyWidget : public QWidget
Q_OBJECT
public:
CppTypeHierarchyWidget();
- ~CppTypeHierarchyWidget() override;
void perform();
@@ -92,6 +92,7 @@ private:
void hideProgress();
void clearTypeHierarchy();
void onItemActivated(const QModelIndex &index);
+ void updateSynchronizer();
CppEditorWidget *m_cppEditor = nullptr;
Utils::NavigationTreeView *m_treeView = nullptr;
@@ -102,7 +103,8 @@ private:
TextEditor::TextEditorLinkLabel *m_inspectedClass = nullptr;
QLabel *m_infoLabel = nullptr;
QFuture<QSharedPointer<CppTools::CppElement>> m_future;
- QFutureWatcher<QSharedPointer<CppTools::CppElement>> m_futureWatcher;
+ QFutureWatcher<void> m_futureWatcher;
+ QFutureSynchronizer<void> m_synchronizer;
Utils::ProgressIndicator *m_progressIndicator = nullptr;
};