diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-08-16 11:42:10 +0000 |
|---|---|---|
| committer | Tarmac <> | 2013-08-16 11:42:10 +0000 |
| commit | 17415e59683af3cf928bc085c74bc7244d8a9e62 (patch) | |
| tree | ea17197b60d566411f6839de3ffd6bb9a1ad61d7 | |
| parent | 933e9fe60d6c121bbbf2e14df3a0213733d75a63 (diff) | |
| parent | 075e1924dd12872591c719d399896f375f47cb85 (diff) | |
Fixed duplicate categories in scope caused by full resync on model change. Fixes: https://bugs.launchpad.net/bugs/1212945.
Approved by PS Jenkins bot, Michal Hruby. (bzr r3473)
| -rwxr-xr-x | dash/ScopeView.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp index ffce422ef..d087b1335 100755 --- a/dash/ScopeView.cpp +++ b/dash/ScopeView.cpp @@ -293,18 +293,11 @@ void ScopeView::SetupCategories(Categories::Ptr const& categories) conn = categories->category_removed.connect(sigc::mem_fun(this, &ScopeView::OnCategoryRemoved)); category_removed_connection_ = conn_manager_.Add(conn); - auto resync_categories = [this, categories] (bool add) - { - ClearCategories(); - if (add) - { - for (unsigned int i = 0; i < categories->count(); ++i) - OnCategoryAdded(categories->RowAtIndex(i)); - } - }; + categories->model.changed.connect(sigc::hide([this]() { ClearCategories(); })); - categories->model.changed.connect(sigc::bind(sigc::hide(resync_categories), false)); - resync_categories(true); + ClearCategories(); + for (unsigned int i = 0; i < categories->count(); ++i) + OnCategoryAdded(categories->RowAtIndex(i)); scope_->category_order.changed.connect(sigc::mem_fun(this, &ScopeView::OnCategoryOrderChanged)); } @@ -393,23 +386,21 @@ void ScopeView::SetupFilters(Filters::Ptr const& filters) conn = filters->filter_removed.connect(sigc::mem_fun(this, &ScopeView::OnFilterRemoved)); filter_removed_connection_ = conn_manager_.Add(conn); - auto resync_filters = [this, filters] (bool add) + auto clear_filters = [this] () { auto conn = conn_manager_.Get(filter_removed_connection_); bool blocked = conn.block(true); filter_bar_->ClearFilters(); - if (add) - { - for (unsigned int i = 0; i < filters->count(); ++i) - OnFilterAdded(filters->FilterAtIndex(i)); - } conn.block(blocked); }; - filters->model.changed.connect(sigc::bind(sigc::hide(resync_filters), false)); - resync_filters(true); + filters->model.changed.connect(sigc::hide(clear_filters)); + + clear_filters(); + for (unsigned int i = 0; i < filters->count(); ++i) + OnFilterAdded(filters->FilterAtIndex(i)); } void ScopeView::OnCategoryAdded(Category const& category) @@ -425,6 +416,7 @@ void ScopeView::OnCategoryAdded(Category const& category) LOG_DEBUG(logger) << "Category added '" << (scope_ ? scope_->name() : "unknown") << "': " << name + << "[" << category.id() << "] " << "(" << icon_hint << ", " << renderer_name << ", " << index << ")"; |
