diff options
| author | hjk <[email protected]> | 2021-07-23 14:02:41 +0200 |
|---|---|---|
| committer | hjk <[email protected]> | 2021-08-02 09:37:39 +0000 |
| commit | 622a03f63c0dc02bbceda31b8e0227cd2a5ea83b (patch) | |
| tree | e7c083a17404e6bc7687dd8f4b276aeb039c4044 /src/plugins | |
| parent | 137df675ca74e74e06f84f3bdbfdfab29ee8ba4f (diff) | |
Core: FilePathify MainWindow::openFiles()
Change-Id: I2d63d9099a7eb5d7c9ea9f1b7d23555a90e737ab
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/coreplugin/mainwindow.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index f985c420130..9bf003a7de2 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -886,13 +886,18 @@ IDocument *MainWindow::openFiles(const FilePaths &filePaths, const QList<IDocumentFactory*> documentFactories = IDocumentFactory::allDocumentFactories(); IDocument *res = nullptr; + const QString workingDirBase = workingDirectory.isEmpty() ? QDir::currentPath() : workingDirectory; for (const FilePath &filePath : filePaths) { - const QString fileName = filePath.toString(); - const QDir workingDir(workingDirectory.isEmpty() ? QDir::currentPath() : workingDirectory); - const QFileInfo fi(workingDir, fileName); - const QString absoluteFilePath = fi.absoluteFilePath(); + const FilePath workingDir = filePath.withNewPath(workingDirBase); + FilePath absoluteFilePath; + if (filePath.isAbsolutePath()) { + absoluteFilePath = filePath; + } else { + QTC_CHECK(!filePath.needsDevice()); + absoluteFilePath = FilePath::fromString(workingDirBase).resolvePath(filePath.path()); + } if (IDocumentFactory *documentFactory = findDocumentFactory(documentFactories, filePath)) { - IDocument *document = documentFactory->open(FilePath::fromString(absoluteFilePath)); + IDocument *document = documentFactory->open(absoluteFilePath); if (!document) { if (flags & ICore::StopOnLoadFail) return res; @@ -909,11 +914,10 @@ IDocument *MainWindow::openFiles(const FilePaths &filePaths, emFlags |= EditorManager::SwitchSplitIfAlreadyVisible; IEditor *editor = nullptr; if (flags & ICore::CanContainLineAndColumnNumbers) { - const Link &link = Link::fromString(absoluteFilePath, true); + const Link &link = Link::fromFilePath(absoluteFilePath, true); editor = EditorManager::openEditorAt(link, {}, emFlags); } else { - const FilePath &filePath = FilePath::fromString(absoluteFilePath); - editor = EditorManager::openEditor(filePath, {}, emFlags); + editor = EditorManager::openEditor(absoluteFilePath, {}, emFlags); } if (!editor) { if (flags & ICore::StopOnLoadFail) @@ -922,10 +926,8 @@ IDocument *MainWindow::openFiles(const FilePaths &filePaths, res = editor->document(); } } else { - auto factory = IEditorFactory::preferredEditorFactories( - FilePath::fromString(absoluteFilePath)).value(0); - DocumentModelPrivate::addSuspendedDocument(FilePath::fromString(absoluteFilePath), - {}, + auto factory = IEditorFactory::preferredEditorFactories(absoluteFilePath).value(0); + DocumentModelPrivate::addSuspendedDocument(absoluteFilePath, {}, factory ? factory->id() : Id()); } } |
