CppEditor: Fix "Rename Symbol Under Cursor" in new split

The slot CPPEditorWidget::onContentsChanged() was still connected to the
initial QTextDocument of BaseTextEditorWidgetPrivate and not to the via
BaseTextEditorWidget::duplicateFrom() updated QTextDocument.

This fixes the visual appearance when renaming. The actual renaming
is/was not affected.

Task-number: QTCREATORBUG-9651
Change-Id: Id26dc11627c253bbf89904be3f3df21a45041d01
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-06-25 15:47:01 +02:00
parent 0855d4acfa
commit b0d9dd0b47
2 changed files with 12 additions and 2 deletions

View File

@@ -641,9 +641,9 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor)
connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateOutlineIndex())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateOutlineIndex()));
connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip())); connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip()));
connect(document(), SIGNAL(contentsChange(int,int,int)),
this, SLOT(onContentsChanged(int,int,int)));
// set up slots to document changes
updateContentsChangedSignal();
connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName())); connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName()));
// set up function declaration - definition link // set up function declaration - definition link
@@ -1870,6 +1870,8 @@ Core::IEditor *CPPEditor::duplicate(QWidget *parent)
{ {
CPPEditorWidget *newEditor = new CPPEditorWidget(parent); CPPEditorWidget *newEditor = new CPPEditorWidget(parent);
newEditor->duplicateFrom(editorWidget()); newEditor->duplicateFrom(editorWidget());
// A new QTextDocument was set, so update our signal/slot connection to the new document
newEditor->updateContentsChangedSignal();
CppEditorPlugin::instance()->initializeEditor(newEditor); CppEditorPlugin::instance()->initializeEditor(newEditor);
return newEditor->editor(); return newEditor->editor();
} }
@@ -2218,6 +2220,12 @@ void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
updateFunctionDeclDefLink(); updateFunctionDeclDefLink();
} }
void CPPEditorWidget::updateContentsChangedSignal()
{
connect(document(), SIGNAL(contentsChange(int,int,int)),
this, SLOT(onContentsChanged(int,int,int)));
}
void CPPEditorWidget::abortDeclDefLink() void CPPEditorWidget::abortDeclDefLink()
{ {
if (!m_declDefLink) if (!m_declDefLink)

View File

@@ -128,6 +128,8 @@ public:
QSharedPointer<FunctionDeclDefLink> declDefLink() const; QSharedPointer<FunctionDeclDefLink> declDefLink() const;
void applyDeclDefLinkChanges(bool jumpToMatch); void applyDeclDefLinkChanges(bool jumpToMatch);
void updateContentsChangedSignal();
Q_SIGNALS: Q_SIGNALS:
void outlineModelIndexChanged(const QModelIndex &index); void outlineModelIndexChanged(const QModelIndex &index);