diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 17cf49bc86609c76f12c0ebde0216e0bc2c81793..2a375ac26f7e94bfcd13d924e8cdce430d1fc071 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -2188,14 +2188,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 && targetEditor != this) {
-        connect(targetEditor, SIGNAL(textChanged()),
-                this, SLOT(abortDeclDefLink()));
+    Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
+                m_declDefLink->targetFile->fileName());
+    if (editorDocument() != targetDocument) {
+        if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
+            connect(baseTextDocument->document(), SIGNAL(contentsChanged()),
+                    this, SLOT(abortDeclDefLink()));
     }
+
 }
 
 void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
@@ -2218,12 +2218,12 @@ void CPPEditorWidget::abortDeclDefLink()
     if (!m_declDefLink)
         return;
 
-    // undo connect from onFunctionDeclDefLinkFound
-    TextEditor::BaseTextEditorWidget *targetEditor =
-            TextEditor::RefactoringChanges::editorForFile(m_declDefLink->targetFile->fileName());
-    if (targetEditor && targetEditor != this) {
-        disconnect(targetEditor, SIGNAL(textChanged()),
-                   this, SLOT(abortDeclDefLink()));
+    Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
+                m_declDefLink->targetFile->fileName());
+    if (editorDocument() != targetDocument) {
+        if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
+            disconnect(baseTextDocument->document(), SIGNAL(contentsChanged()),
+                    this, SLOT(abortDeclDefLink()));
     }
 
     m_declDefLink->hideMarker(this);
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index fdc931e50a8c5bb16e382aeff44b03ee33b7514c..2b91bc5b802866c5fd9edbc007e9fcf5c1f888f2 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -2592,8 +2592,8 @@ public:
                            m_loc.prefix().count(QLatin1String("\n")) + 2);
             c.movePosition(QTextCursor::EndOfLine);
             if (m_defpos == DefPosImplementationFile) {
-                if (BaseTextEditorWidget *editor = refactoring.editorForFile(m_loc.fileName()))
-                    editor->setTextCursor(c);
+                if (targetFile->editor())
+                    targetFile->editor()->setTextCursor(c);
             } else {
                 assistInterface()->editor()->setTextCursor(c);
             }
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index f5e43b32ac6d70799c54ffd1f5f7834a6a037216..4d1cf136881575ba5ab3f94178945aacbcdc9174 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -56,19 +56,6 @@ RefactoringChanges::RefactoringChanges(RefactoringChangesData *data)
 RefactoringChanges::~RefactoringChanges()
 {}
 
-BaseTextEditorWidget *RefactoringChanges::editorForFile(const QString &fileName)
-{
-    Core::EditorManager *editorManager = Core::EditorManager::instance();
-
-    const QList<Core::IEditor *> editors = editorManager->editorsForFileName(fileName);
-    foreach (Core::IEditor *editor, editors) {
-        BaseTextEditorWidget *textEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget());
-        if (textEditor != 0)
-            return textEditor;
-    }
-    return 0;
-}
-
 QList<QPair<QTextCursor, QTextCursor > > RefactoringChanges::rangesToSelections(QTextDocument *document,
                                                                                 const QList<Range> &ranges)
 {
@@ -190,7 +177,9 @@ RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer<R
     , m_editorCursorPosition(-1)
     , m_appliedOnce(false)
 {
-    m_editor = RefactoringChanges::editorForFile(fileName);
+    QList<Core::IEditor *> editors = Core::EditorManager::documentModel()->editorsForFilePath(fileName);
+    if (!editors.isEmpty())
+        m_editor = qobject_cast<TextEditor::BaseTextEditorWidget *>(editors.first()->widget());
 }
 
 RefactoringFile::~RefactoringFile()
@@ -251,6 +240,11 @@ QString RefactoringFile::fileName() const
     return m_fileName;
 }
 
+BaseTextEditorWidget *RefactoringFile::editor() const
+{
+    return m_editor;
+}
+
 int RefactoringFile::position(unsigned line, unsigned column) const
 {
     QTC_ASSERT(line != 0, return -1);
diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h
index 3a33901b0aa407e2184d786c8d71cbb15426119d..f97056777e17d41f7793331a792466981e290528 100644
--- a/src/plugins/texteditor/refactoringchanges.h
+++ b/src/plugins/texteditor/refactoringchanges.h
@@ -66,6 +66,7 @@ public:
     // mustn't use the cursor to change the document
     const QTextCursor cursor() const;
     QString fileName() const;
+    BaseTextEditorWidget *editor() const;
 
     // converts 1-based line and column into 0-based source offset
     int position(unsigned line, unsigned column) const;
@@ -134,8 +135,6 @@ public:
     bool createFile(const QString &fileName, const QString &contents, bool reindent = true, bool openEditor = true) const;
     bool removeFile(const QString &fileName) const;
 
-    static BaseTextEditorWidget *editorForFile(const QString &fileName);
-
 protected:
     explicit RefactoringChanges(RefactoringChangesData *data);