Commit 0f0fa3c2 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Editor: Check if file exists before extracting line no.

Correct also checking for flag value.

Task-Number: QTCREATORBUG-8272

Change-Id: I5f919d9c79639a04c05900dc8be950855478a3fe
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 46101b0b
......@@ -1272,9 +1272,13 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
qDebug() << Q_FUNC_INFO << fileName << editorId.name();
QString fn = fileName;
QFileInfo fi(fn);
int lineNumber = -1;
if (flags && EditorManager::CanContainLineNumber)
if ((flags & EditorManager::CanContainLineNumber) && !fi.exists()) {
lineNumber = extractLineNumber(&fn);
if (lineNumber != -1)
fi.setFile(fn);
}
if (fn.isEmpty())
return 0;
......@@ -1285,13 +1289,12 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
const QList<IEditor *> editors = editorsForFileName(fn);
if (!editors.isEmpty()) {
IEditor *editor = editors.first();
if (flags && EditorManager::CanContainLineNumber)
if (flags & EditorManager::CanContainLineNumber)
editor->gotoLine(lineNumber, -1);
return activateEditor(view, editor, flags);
}
QString realFn = autoSaveName(fn);
QFileInfo fi(fn);
QFileInfo rfi(realFn);
if (!fi.exists() || !rfi.exists() || fi.lastModified() >= rfi.lastModified()) {
QFile::remove(realFn);
......@@ -1325,7 +1328,7 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
if (editor == result)
restoreEditorState(editor);
if (flags && EditorManager::CanContainLineNumber)
if (flags & EditorManager::CanContainLineNumber)
editor->gotoLine(lineNumber, -1);
QApplication::restoreOverrideCursor();
......
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