From b281d6f00af6a3ceb590ac4cd58fc297bae882c9 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 30 Nov 2020 17:02:33 +0100 Subject: [PATCH] Don't call CppTypeHierarchyWidget::perform() twice In case a Type Hierarchy widget isn't visible, the CppIncludeHierarchyWidget::perform() is called twice when requested from "Open Type Hierarchy" context menu. The instances of CppIncludeHierarchyWidget class are created only when Type Hierarchy item is selected form the combobox, and are destroyed when different item is selected. A call to: NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left) may be ignored (in case Type Hierarchy widget was visible) or may recreate the widget and invoke CppTypeHierarchyWidget::perform() for the first time (in case when Type Hierarchy wasn't visible). Just after this we emit typeHierarchyRequested(), which in turn invokes perform() one more time unconditionally. In order to fix it, we emit the signal typeHierarchyRequested() first (which will invoke perform() only when the Type Hierarchy widget was visible), and later call activateSubWidget(), which invoke perform only when we are recreating a widget. This shorten the freeze time for calculating big hierarchies, like for ExtensionSystem::IPlugin, by 50%. We do the same for CppIncludeHierarchyWidget. Change-Id: If58fba4ba1dc32999d106fc2faa712e05442caf3 Reviewed-by: Eike Ziller Reviewed-by: Christian Kandeler --- src/plugins/cppeditor/cppeditorplugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 7d8ac561549..a3456b1c374 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -386,16 +386,16 @@ QVector CppEditorPlugin::createTestObjects() const void CppEditorPlugin::openTypeHierarchy() { if (currentCppEditorWidget()) { - NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left); emit typeHierarchyRequested(); + NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left); } } void CppEditorPlugin::openIncludeHierarchy() { if (currentCppEditorWidget()) { - NavigationWidget::activateSubWidget(Constants::INCLUDE_HIERARCHY_ID, Side::Left); emit includeHierarchyRequested(); + NavigationWidget::activateSubWidget(Constants::INCLUDE_HIERARCHY_ID, Side::Left); } }