From be72339b2de9fd3f2cd12b2f1b559b2a32f595ad Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 12 Aug 2014 09:59:00 -0400 Subject: [PATCH 1/8] filter: Check for empty results when filtering The user could search for a term that isn't stored in the filter index. This is represented through a NULL pointer returned from the Index.find() function. Let's check this pointer before attempting to dereference it ... Signed-off-by: Anna Schumaker --- core/filter.cpp | 15 +++++++++++---- tests/core/filter.cpp | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/filter.cpp b/core/filter.cpp index 941c797f..a998c759 100644 --- a/core/filter.cpp +++ b/core/filter.cpp @@ -90,14 +90,21 @@ std::string filter :: add(const std::string &text, unsigned int track_id) return reassemble_text(parsed); } +static void do_set_intersection(std::set &a, + std::set &b, + std::set &res) +{ + set_intersection(a.begin(), a.end(), b.begin(), b.end(), + std::inserter >(res, res.begin())); +} + static void find_intersection(std::string &text, std::set &res) { - IndexEntry *it = filter_index.find(text); std::set tmp; + IndexEntry *it = filter_index.find(text); - set_intersection(it->values.begin(), it->values.end(), - res.begin(), res.end(), - std::inserter >(tmp, tmp.begin())); + if (it) + do_set_intersection(res, it->values, tmp); res.swap(tmp); } diff --git a/tests/core/filter.cpp b/tests/core/filter.cpp index 75b27767..7e5781c0 100644 --- a/tests/core/filter.cpp +++ b/tests/core/filter.cpp @@ -96,6 +96,9 @@ static void test_search() unsigned int res5[] = {}; do_test_search("unknown terms", 0, res5); + + unsigned int res6[] = {}; + do_test_search("the chestZ", 0, res6); } int main(int argc, char **argv) From 8fd5d8173e472284c13807a7cff9003dc3ec0350 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 12 Aug 2014 10:19:56 -0400 Subject: [PATCH 2/8] filter: Clear the result set before filtering Ocarina was preserving the results set even if there were 0 search results for the entire search string. So a search for "walllllll" would still return results for "wall". Signed-off-by: Anna Schumaker --- core/filter.cpp | 1 + tests/core/filter.cpp | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/filter.cpp b/core/filter.cpp index a998c759..71a82ccb 100644 --- a/core/filter.cpp +++ b/core/filter.cpp @@ -114,6 +114,7 @@ void filter :: search(const std::string &text, std::set &res) std::list::iterator it; IndexEntry *found; + res.clear(); parse_text(text, parsed); if (parsed.size() == 0) return; diff --git a/tests/core/filter.cpp b/tests/core/filter.cpp index 7e5781c0..127e70f5 100644 --- a/tests/core/filter.cpp +++ b/tests/core/filter.cpp @@ -64,7 +64,8 @@ static void test_add() static void do_test_search(const std::string &text, unsigned int len, unsigned int *ids) { - std::set res; + int init_values[] = { 1, 2, 3, 4, 5 }; + std::set res(init_values, init_values + 5); std::set::iterator it; filter :: search(text, res); @@ -96,9 +97,7 @@ static void test_search() unsigned int res5[] = {}; do_test_search("unknown terms", 0, res5); - - unsigned int res6[] = {}; - do_test_search("the chestZ", 0, res6); + do_test_search("the chestZ", 0, res5); } int main(int argc, char **argv) From 76a5e0b6badefb6721efd60cf90c983ffd8c9528 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 12 Aug 2014 10:40:34 -0400 Subject: [PATCH 3/8] Ocarina 6.1.2 Signed-off-by: Anna Schumaker --- Sconstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sconstruct b/Sconstruct index 81bcc17f..a61bdc88 100644 --- a/Sconstruct +++ b/Sconstruct @@ -2,7 +2,7 @@ import os # Configuration variables -CONFIG_VERSION = "6.1.1" +CONFIG_VERSION = "6.1.2" CONFIG_DEBUG = False CONFIG_TEST_VALGRIND = False CONFIG_TEST_COVERAGE = False From d185b29d7b529406a347ae1f19d7760a94ce04d0 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:00:51 -0400 Subject: [PATCH 4/8] PKGBUILD: 6.1.2 Update Signed-off-by: Anna Schumaker --- PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 0c2d6f95..7a97d90a 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Anna Schumaker pkgname=ocarina -pkgver=6.1.1 +pkgver=6.1.2 pkgrel=1 pkgdesc="A simple GTK and gstreamer based music player." url="http://www.ocarinaproject.net/" @@ -13,7 +13,7 @@ conflicts=() replaces=() backup=() source=("http://ocarinaproject.net/wp-content/ocarina/${pkgname}-${pkgver}.tar.gz") -sha1sums=('7fa6275aeba85b86988b5a3c88bafc7c6e36ec88') +sha1sums=('b35eed8e05c254efa1de8d7868b63f56bf8f178a') build() { cd "${srcdir}/${pkgname}-${pkgver}" From cfa61fa8160be9037ce432fd3c976a1ed04ff555 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:01:20 -0400 Subject: [PATCH 5/8] gui: Play next song after banning If the user tells us they don't like the current song then we shouldn't keep playing it! Signed-off-by: Anna Schumaker --- gui/gui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/gui.cpp b/gui/gui.cpp index a9c54d99..5c21cdd5 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -107,9 +107,10 @@ static void on_ban_toggled() { Gtk::ToggleButton *ban = get_widget("o_ban"); - if (ban->get_active() == true) + if (ban->get_active() == true) { playlist :: add(audio :: current_track(), "Banned"); - else + on_next(); + } else playlist :: del(audio::current_track(), "Banned"); } From 41506f31770757afb45d94d7be582771a4fb77ed Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:16:48 -0400 Subject: [PATCH 6/8] gui: Remove banned songs from Collection when re-enabling I wasn't doing this before, so banned songs were showing up in the collection list again. I think this is kind of an ugly fix, though. Perhaps there is a better way to do it? Signed-off-by: Anna Schumaker --- gui/collection_mgr.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index 6cafc087..63d237b3 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -2,7 +2,9 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include +#include #include static void on_library_add(unsigned int id, Library *library); @@ -80,6 +82,18 @@ static bool on_collection_key_pressed(GdkEventKey *event) return false; } +static void on_enabled_remove_banned() +{ + std::set::iterator it; + IndexEntry *ent = playlist :: get_tracks("Banned"); + + if (!ent) + return; + + for (it = ent->values.begin(); it != ent->values.end(); it++) + library :: get_queue()->del(tagdb :: lookup(*it)); +} + #ifndef CONFIG_TEST static #endif /* CONFIG_TEST */ @@ -87,9 +101,13 @@ void on_collection_toggled(const Glib::ustring &path) { Glib::RefPtr list = get_collection_list(); Gtk::TreeModel::Row row = *(list->get_iter(path)); + row[collection_cols.c_col_enabled] = !row[collection_cols.c_col_enabled]; library :: set_enabled(tagdb :: lookup_library(row[collection_cols.c_col_id]), row[collection_cols.c_col_enabled]); + + if (row[collection_cols.c_col_enabled] == true) + on_enabled_remove_banned(); } static void on_library_add(unsigned int id, Library *library) From 654bb99c6d0a52fcdb56f9555db6c793bdb6c4e8 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:18:45 -0400 Subject: [PATCH 7/8] Ocarina 6.1.3 Signed-off-by: Anna Schumaker --- Sconstruct | 2 +- share/ocarina/ocarina6.glade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sconstruct b/Sconstruct index a61bdc88..2aebd947 100644 --- a/Sconstruct +++ b/Sconstruct @@ -2,7 +2,7 @@ import os # Configuration variables -CONFIG_VERSION = "6.1.2" +CONFIG_VERSION = "6.1.3" CONFIG_DEBUG = False CONFIG_TEST_VALGRIND = False CONFIG_TEST_COVERAGE = False diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 867554b4..3f37a752 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -212,7 +212,7 @@ True False - Ocarina 6.1.1 + Ocarina 6.1.3 1024 683 From 345ad705ce2b2f89f06099e5a8791397fd99d362 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:20:58 -0400 Subject: [PATCH 8/8] PKGBUILD: Updates for 6.1.3 Signed-off-by: Anna Schumaker --- PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 7a97d90a..f49bcff7 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Anna Schumaker pkgname=ocarina -pkgver=6.1.2 +pkgver=6.1.3 pkgrel=1 pkgdesc="A simple GTK and gstreamer based music player." url="http://www.ocarinaproject.net/" @@ -13,7 +13,7 @@ conflicts=() replaces=() backup=() source=("http://ocarinaproject.net/wp-content/ocarina/${pkgname}-${pkgver}.tar.gz") -sha1sums=('b35eed8e05c254efa1de8d7868b63f56bf8f178a') +sha1sums=('d54ba4ca864d988475337a8b44feec0f84cc46d1') build() { cd "${srcdir}/${pkgname}-${pkgver}"