From f262f1b66e32205eff6725ae88a0541bc78fc4f2 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 2 Oct 2014 22:28:28 +0200 Subject: [PATCH] Media Preflet: Use BPathFinder::FindPaths() instead of the C method. This way we can use BStringList and get rid of the manual deallocation. --- src/preferences/media/MidiSettingsView.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/preferences/media/MidiSettingsView.cpp b/src/preferences/media/MidiSettingsView.cpp index 340b2d0011..2ea0143f32 100644 --- a/src/preferences/media/MidiSettingsView.cpp +++ b/src/preferences/media/MidiSettingsView.cpp @@ -17,10 +17,12 @@ #include #include #include +#include #include +#include #include -#include + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Midi View" @@ -89,17 +91,16 @@ MidiSettingsView::MessageReceived(BMessage* message) void MidiSettingsView::_RetrieveSoftSynthList() { - char **paths = NULL; - size_t pathCount = 0; - status_t status = find_paths(B_FIND_PATH_DATA_DIRECTORY, "synth", - &paths, &pathCount); + BStringList paths; + status_t status = BPathFinder::FindPaths(B_FIND_PATH_DATA_DIRECTORY, + "synth", paths); if (status != B_OK) return; fListView->MakeEmpty(); - for (size_t i = 0; i < pathCount; i++) { - BDirectory directory(paths[i]); + for (int32 i = 0; i < paths.CountStrings(); i++) { + BDirectory directory(paths.StringAt(i).String()); BEntry entry; if (directory.InitCheck() != B_OK) continue; @@ -115,14 +116,12 @@ MidiSettingsView::_RetrieveSoftSynthList() // TODO: For some reason this doesn't work if (nodeInfo.GetType(mimeType) == B_OK /*&& !strcmp(mimeType, "audio/x-soundfont")*/) { - BPath fullPath = paths[i]; + BPath fullPath = paths.StringAt(i).String(); fullPath.Append(entry.Name()); fListView->AddItem(new BStringItem(fullPath.Path())); } } } - - free(paths); }