Skip to content

Commit

Permalink
fix to error if directory contents are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
haraki committed May 27, 2019
1 parent d81048f commit e5bff55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 11 additions & 8 deletions folderform.cpp
Expand Up @@ -168,8 +168,18 @@ int FolderForm::setPath(const QString& dirPath)

FilterFlags filterFlags = m_folderModel->getFilterFlags();

QDir nextDir = QDir(dirPath);

// ディレクトリが空(".." も存在しない)場合は Open できないとみなしてエラー
if(nextDir.isEmpty(QDir::AllEntries | QDir::NoDot))
{
qDebug() << dirPath << " size() == 0";

return -1;
}

// ルートディレクトリの場合は".."を表示しないようにする
if(QDir(dirPath).isRoot())
if(nextDir.isRoot())
{
filterFlags &= ~static_cast<int>(FilterFlag::Parent);
}
Expand All @@ -178,13 +188,6 @@ int FolderForm::setPath(const QString& dirPath)
filterFlags |= FilterFlag::Parent;
}

// if(dir.entryInfoList(filterFlags).size() == 0)
// {
// qDebug() << dirPath << " size() == 0";

// return -1;
// }

m_isSettingPath = true;

m_folderModel->clearSelected();
Expand Down
1 change: 0 additions & 1 deletion foldermodel.cpp
Expand Up @@ -22,7 +22,6 @@ static Q_DECL_CONSTEXPR QDir::Filters FIX_FILTER_FLAGS = QDir::AllEntries |
QDir::Executable |
QDir::Modified |
QDir::System |
QDir::AllDirs |
QDir::NoDot;


Expand Down

0 comments on commit e5bff55

Please sign in to comment.