From 3388281fb7b8bc9a31d353ded0f99daadf70d6ca Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 13 May 2012 00:57:25 +0000 Subject: [PATCH] Fix error when the style catalog directory doesn't exist or is empty Use wxDir::GetFirst/GetNext rather than wxFileFirstFile since the latter doesn't have any way to signal that there aren't actually any files to be found. Closes #1486. Originally committed to SVN as r6764. --- aegisub/src/dialog_style_manager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 4c032a090..763ea48c2 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -336,9 +336,14 @@ void DialogStyleManager::LoadCatalog() { CatalogList->Clear(); // Get saved style catalogs - wxString dirname = StandardPaths::DecodePath("?user/catalog/*.sty"); - for (wxString curfile = wxFindFirstFile(dirname, wxFILE); !curfile.empty(); curfile = wxFindNextFile()) - CatalogList->Append(wxFileName(curfile).GetName()); + wxDir dir(StandardPaths::DecodePath("?user/catalog/")); + if (dir.IsOpened()) { + wxString curfile; + if (dir.GetFirst(&curfile, "*.sty", wxDIR_FILES)) + CatalogList->Append(wxFileName(curfile).GetName()); + while (dir.GetNext(&curfile)) + CatalogList->Append(wxFileName(curfile).GetName()); + } // Create a default storage if there are none if (CatalogList->IsListEmpty())