From a0cddc579f6575a00fbe79df06cb80326fb52c33 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 15 Sep 2017 19:44:23 +0200 Subject: [PATCH] DolphinQt2: Check for file systems being nullptr nullptr gets returned for file systems that are deemed invalid. --- .../DolphinQt2/Config/FilesystemWidget.cpp | 20 +++++++++++++++---- .../Core/DolphinQt2/Config/FilesystemWidget.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp index 0b9fc9e0e6..f4e5f2651e 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp @@ -85,8 +85,6 @@ void FilesystemWidget::PopulateView() for (size_t i = 0; i < partitions.size(); i++) { - const DiscIO::FileSystem* file_system = m_volume->GetFileSystem(partitions[i]); - auto* item = new QStandardItem(tr("Partition %1").arg(i)); item->setEditable(false); @@ -94,7 +92,7 @@ void FilesystemWidget::PopulateView() item->setData(static_cast(i), ENTRY_PARTITION); item->setData(QVariant::fromValue(EntryType::Partition), ENTRY_TYPE); - PopulateDirectory(static_cast(i), item, file_system->GetRoot()); + PopulateDirectory(static_cast(i), item, partitions[i]); disc->appendRow(item); @@ -103,7 +101,15 @@ void FilesystemWidget::PopulateView() } if (partitions.empty()) - PopulateDirectory(-1, disc, m_volume->GetFileSystem(DiscIO::PARTITION_NONE)->GetRoot()); + PopulateDirectory(-1, disc, DiscIO::PARTITION_NONE); +} + +void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root, + const DiscIO::Partition& partition) +{ + const DiscIO::FileSystem* const file_system = m_volume->GetFileSystem(partition); + if (file_system) + PopulateDirectory(partition_id, root, file_system->GetRoot()); } void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root, @@ -234,6 +240,9 @@ void FilesystemWidget::ExtractDirectory(const DiscIO::Partition& partition, cons const QString& out) { const DiscIO::FileSystem* filesystem = m_volume->GetFileSystem(partition); + if (!filesystem) + return; + std::unique_ptr info = filesystem->FindFileInfo(path.toStdString()); u32 size = info->GetTotalChildren(); @@ -263,6 +272,9 @@ void FilesystemWidget::ExtractFile(const DiscIO::Partition& partition, const QSt const QString& out) { const DiscIO::FileSystem* filesystem = m_volume->GetFileSystem(partition); + if (!filesystem) + return; + bool success = DiscIO::ExportFile( *m_volume, partition, filesystem->FindFileInfo(path.toStdString()).get(), out.toStdString()); diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.h b/Source/Core/DolphinQt2/Config/FilesystemWidget.h index deabc20442..88fdf16ce0 100644 --- a/Source/Core/DolphinQt2/Config/FilesystemWidget.h +++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.h @@ -30,6 +30,7 @@ private: void CreateWidgets(); void ConnectWidgets(); void PopulateView(); + void PopulateDirectory(int partition_id, QStandardItem* root, const DiscIO::Partition& partition); void PopulateDirectory(int partition_id, QStandardItem* root, const DiscIO::FileInfo& directory); void ShowContextMenu(const QPoint&);