diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 2f6a30c..dc0d066 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -678,10 +678,21 @@ void DirView::setDir(const QString &path) if(oldPath.left(ROOT_LEN) != path.left(ROOT_LEN)) _dirFileSystemModel->setRootPath(path.left(ROOT_LEN)); - _dirFileSystemModel->setDir(path); - setRootIndex(_dirFileSystemModel->index(path, 0)); + QString newPath = path; + if(!QFileInfo::exists(path)) + { + QDir dir(path); + do + { + dir.setPath(QDir::cleanPath(dir.filePath(".."))); + }while(!dir.exists() && !dir.isRoot()); + newPath = dir.path(); + } + + _dirFileSystemModel->setDir(newPath); + setRootIndex(_dirFileSystemModel->index(newPath, 0)); clearSelection(); - if(oldPath != path)emit dirChanged(path); + if(oldPath != newPath)emit dirChanged(newPath); } QString DirView::dir() const