Merge pull request #5534 from JosJuice/dont-bind-no-filesystem

DolphinWX: Don't bind context menu when GC filesystem is invalid
This commit is contained in:
Leo Lam 2017-06-04 15:02:32 +02:00 committed by GitHub
commit 4e584ec039
2 changed files with 10 additions and 7 deletions

View File

@ -159,10 +159,11 @@ FilesystemPanel::FilesystemPanel(wxWindow* parent, wxWindowID id,
: wxPanel{parent, id}, m_opened_iso{opened_iso} : wxPanel{parent, id}, m_opened_iso{opened_iso}
{ {
CreateGUI(); CreateGUI();
BindEvents(); if (PopulateFileSystemTree())
PopulateFileSystemTree(); {
BindEvents();
m_tree_ctrl->Expand(m_tree_ctrl->GetRootItem()); m_tree_ctrl->Expand(m_tree_ctrl->GetRootItem());
}
} }
FilesystemPanel::~FilesystemPanel() = default; FilesystemPanel::~FilesystemPanel() = default;
@ -194,7 +195,7 @@ void FilesystemPanel::CreateGUI()
SetSizer(main_sizer); SetSizer(main_sizer);
} }
void FilesystemPanel::PopulateFileSystemTree() bool FilesystemPanel::PopulateFileSystemTree()
{ {
const std::vector<DiscIO::Partition> partitions = m_opened_iso->GetPartitions(); const std::vector<DiscIO::Partition> partitions = m_opened_iso->GetPartitions();
m_has_partitions = !partitions.empty(); m_has_partitions = !partitions.empty();
@ -224,10 +225,12 @@ void FilesystemPanel::PopulateFileSystemTree()
{ {
m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get(), DiscIO::PARTITION_NONE); m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get(), DiscIO::PARTITION_NONE);
if (!m_filesystem) if (!m_filesystem)
return; return false;
CreateDirectoryTree(m_tree_ctrl, m_tree_ctrl->GetRootItem(), m_filesystem->GetFileList()); CreateDirectoryTree(m_tree_ctrl, m_tree_ctrl->GetRootItem(), m_filesystem->GetFileList());
} }
return true;
} }
void FilesystemPanel::OnRightClickTree(wxTreeEvent& event) void FilesystemPanel::OnRightClickTree(wxTreeEvent& event)

View File

@ -39,7 +39,7 @@ private:
void CreateGUI(); void CreateGUI();
void BindEvents(); void BindEvents();
void PopulateFileSystemTree(); bool PopulateFileSystemTree();
void OnRightClickTree(wxTreeEvent&); void OnRightClickTree(wxTreeEvent&);
void OnExtractFile(wxCommandEvent&); void OnExtractFile(wxCommandEvent&);