From abdbae33083164b4021884fee500cf325ffc8994 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Tue, 5 Nov 2013 14:02:13 +0100 Subject: CppEditor: "Include Hierarchy": using snapshot from snapshotUpdater For "includes" we should use snapshot from "SnapshotUpdater"(project specific snapshot, not global snapshot) instead of "global" snapshot. The snapshot of the editor's SnapshotUpdater contains the documents parsed with the appropriate include paths/defines etc. and should therefore be used for the include hierarchy. Change-Id: I6bbaf5040536b771d32697aad1db364758ff8382 Reviewed-by: Nikolai Kosjar --- src/plugins/cppeditor/cppincludehierarchy.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/plugins/cppeditor/cppincludehierarchy.cpp') diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp index 15a2429f82..3efde4c154 100644 --- a/src/plugins/cppeditor/cppincludehierarchy.cpp +++ b/src/plugins/cppeditor/cppincludehierarchy.cpp @@ -36,6 +36,7 @@ #include "cppincludehierarchymodel.h" #include "cppincludehierarchytreeview.h" +#include #include #include @@ -89,7 +90,8 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget() : m_treeView(0), m_model(0), m_delegate(0), - m_includeHierarchyInfoLabel(0) + m_includeHierarchyInfoLabel(0), + m_editor(0) { m_inspectedFile = new CppIncludeLabel(this); m_inspectedFile->setMargin(5); @@ -118,6 +120,9 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget() : setLayout(layout); connect(CppEditorPlugin::instance(), SIGNAL(includeHierarchyRequested()), SLOT(perform())); + connect(Core::EditorManager::instance(), SIGNAL(editorsClosed(QList)), + this, SLOT(editorsClosed(QList))); + } CppIncludeHierarchyWidget::~CppIncludeHierarchyWidget() @@ -128,15 +133,16 @@ void CppIncludeHierarchyWidget::perform() { showNoIncludeHierarchyLabel(); - CPPEditor *editor = qobject_cast(Core::EditorManager::currentEditor()); - if (!editor) + m_editor = qobject_cast(Core::EditorManager::currentEditor()); + if (!m_editor) return; - CPPEditorWidget *widget = qobject_cast(editor->widget()); + + CPPEditorWidget *widget = qobject_cast(m_editor->widget()); if (!widget) return; m_model->clear(); - m_model->buildHierarchy(widget->editorDocument()->filePath()); + m_model->buildHierarchy(m_editor, widget->editorDocument()->filePath()); if (m_model->isEmpty()) return; @@ -162,6 +168,14 @@ void CppIncludeHierarchyWidget::onItemClicked(const QModelIndex &index) Constants::CPPEDITOR_ID); } +void CppIncludeHierarchyWidget::editorsClosed(QList editors) +{ + foreach (Core::IEditor *editor, editors) { + if (m_editor == editor) + perform(); + } +} + void CppIncludeHierarchyWidget::showNoIncludeHierarchyLabel() { m_inspectedFile->hide(); -- cgit v1.2.1