From 00c4aebeaafe08d6834c90b097c5018493ee62ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 22 Nov 2016 00:56:48 +0100 Subject: [PATCH] GH-1731 more screenshot folder view hardening --- application/pages/ScreenshotsPage.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/application/pages/ScreenshotsPage.cpp b/application/pages/ScreenshotsPage.cpp index c40e391b..d58a5d63 100644 --- a/application/pages/ScreenshotsPage.cpp +++ b/application/pages/ScreenshotsPage.cpp @@ -351,12 +351,23 @@ void ScreenshotsPage::on_renameBtn_clicked() void ScreenshotsPage::opened() { + if(!m_valid) + { + m_valid = FS::ensureFolderPathExists(m_folder); + } if (m_valid) { - ui->listView->setModel(m_filterModel.get()); QString path = QDir(m_folder).absolutePath(); - m_model->setRootPath(path); - ui->listView->setRootIndex(m_filterModel->mapFromSource(m_model->index(path))); + auto idx = m_model->setRootPath(path); + if(idx.isValid()) + { + ui->listView->setModel(m_filterModel.get()); + ui->listView->setRootIndex(m_filterModel->mapFromSource(idx)); + } + else + { + ui->listView->setModel(nullptr); + } } }