diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 7ca2d32cd67..ab0c3bdeae9 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -227,12 +227,19 @@ void CppEditorWidget::finalizeInitialization() connect(d->m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget())); insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_preprocessorButton); insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_cppEditorOutline->widget()); +} -// updateSemanticInfo(semanticInfo()); -// updateFunctionDeclDefLink(); -// d->m_cppEditorOutline->update(); -// const ExtraSelectionKind selectionKind = CodeWarningsSelection; -// setExtraSelections(selectionKind, extraSelections(selectionKind)); +void CppEditorWidget::finalizeInitializationAfterDuplication(BaseTextEditorWidget *other) +{ + QTC_ASSERT(other, return); + CppEditorWidget *cppEditorWidget = qobject_cast(other); + QTC_ASSERT(cppEditorWidget, return); + + if (cppEditorWidget->isSemanticInfoValidExceptLocalUses()) + updateSemanticInfo(cppEditorWidget->semanticInfo()); + d->m_cppEditorOutline->update(); + const ExtraSelectionKind selectionKind = CodeWarningsSelection; + setExtraSelections(selectionKind, cppEditorWidget->extraSelections(selectionKind)); } CppEditorWidget::~CppEditorWidget() diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 4a22d1ec987..d7481cd1f75 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -73,8 +73,6 @@ public: CppEditorWidget(); ~CppEditorWidget(); - void finalizeInitialization(); - CppEditorDocument *cppEditorDocument() const; CppEditorOutline *outline() const; @@ -143,6 +141,9 @@ private slots: void processKeyNormally(QKeyEvent *e); private: + void finalizeInitialization() QTC_OVERRIDE; + void finalizeInitializationAfterDuplication(BaseTextEditorWidget *other) QTC_OVERRIDE; + static bool openCppEditorAt(const Link &, bool inNextSplit = false); unsigned documentRevision() const; diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 759b73698ca..86000507e34 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -7284,7 +7284,9 @@ void BaseTextEditorFactory::setEditorActionHandlers(uint optionalActions) BaseTextEditor *BaseTextEditorFactory::duplicateTextEditor(BaseTextEditor *other) { - return createEditorHelper(other->editorWidget()->textDocumentPtr()); + BaseTextEditor *editor = createEditorHelper(other->editorWidget()->textDocumentPtr()); + editor->editorWidget()->finalizeInitializationAfterDuplication(other->editorWidget()); + return editor; } IEditor *BaseTextEditorFactory::createEditor() diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index ffa17c62c29..18efca4febb 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -548,6 +548,7 @@ protected: void showDefaultContextMenu(QContextMenuEvent *e, Core::Id menuContextId); virtual void finalizeInitialization() {} + virtual void finalizeInitializationAfterDuplication(BaseTextEditorWidget *) {} public: struct Link