Commit 4e1d92fd authored by Christian Kamm's avatar Christian Kamm

C++ function link: Disable link if target editor changes.

Change-Id: I7041f3c520e88b4376c5cbac08ed79aa44641f0f
Reviewed-on: http://codereview.qt.nokia.com/3088Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent a59bca80
......@@ -2302,6 +2302,14 @@ void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
{
abortDeclDefLink();
m_declDefLink = link;
// disable the link if content of the target editor changes
TextEditor::BaseTextEditorWidget *targetEditor =
TextEditor::RefactoringChanges::editorForFile(link->targetFile->fileName());
if (targetEditor) {
connect(targetEditor, SIGNAL(textChanged()),
this, SLOT(abortDeclDefLink()));
}
}
void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
......@@ -2317,6 +2325,15 @@ void CPPEditorWidget::abortDeclDefLink()
{
if (!m_declDefLink)
return;
// undo connect from onFunctionDeclDefLinkFound
TextEditor::BaseTextEditorWidget *targetEditor =
TextEditor::RefactoringChanges::editorForFile(m_declDefLink->targetFile->fileName());
if (targetEditor) {
disconnect(targetEditor, SIGNAL(textChanged()),
this, SLOT(abortDeclDefLink()));
}
m_declDefLink->hideMarker(this);
m_declDefLink.clear();
}
......
......@@ -269,7 +269,7 @@ private:
void abortRename();
void applyDeclDefLinkChanges(bool jumpToMatch);
void abortDeclDefLink();
Q_SLOT void abortDeclDefLink();
Link attemptFuncDeclDef(const QTextCursor &cursor,
const CPlusPlus::Document::Ptr &doc,
......
......@@ -120,11 +120,10 @@ public:
*/
void activateEditor(const QString &fileName, int line, int column);
private:
static BaseTextEditorWidget *editorForFile(const QString &fileName,
bool openIfClosed = false);
private:
static QList<QTextCursor> rangesToSelections(QTextDocument *document, const QList<Range> &ranges);
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment