core/collection: Fix some memory leaks

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-05 14:27:30 -05:00
parent ffa12a2c38
commit 8e5cc543c3
2 changed files with 15 additions and 8 deletions

View File

@ -63,8 +63,8 @@ static void scan_path(void *data)
name = g_dir_read_name(dir);
}
track_db_commit();
g_dir_close(dir);
track_db_commit();
delete scan;
}
@ -180,14 +180,16 @@ void collection_remove(struct library *library)
void collection_update(struct library *library)
{
struct scan_info *scan = new struct scan_info;
scan->library = library;
struct scan_info *scan;
if (library) {
scan->path = library->li_path;
idle_schedule(validate_library, library);
idle_schedule(scan_path, scan);
}
if (!library)
return;
scan = new struct scan_info;
scan->library = library;
scan->path = library->li_path;
idle_schedule(validate_library, library);
idle_schedule(scan_path, scan);
}
void collection_update_all()

View File

@ -64,6 +64,11 @@ static void test_update()
struct queue *q = collection_get_queue();
struct library *lib = library_get(0);
collection_update(NULL);
test_equal(track_db_get()->db_size, 48);
test_equal(lib->li_size, 48);
test_equal(queue_size(q), 48);
g_rename("tests/Music/Hyrule Symphony/", "tests/Music/symphony/");
collection_update(lib);