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.
This commit is contained in:
Thomas Goyne 2012-05-13 00:57:25 +00:00
parent 2addf40b31
commit 3388281fb7

View file

@ -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())