@@ -21,6 +21,7 @@
22#include "categories.h"
22#include "categories.h"
23#include "categoryresults.h"
23#include "categoryresults.h"
25// TODO: use something from libunity once it's public
26// TODO: use something from libunity once it's public
26enum CategoryColumn {
27enum CategoryColumn {
@@ -62,7 +63,16 @@ Categories::getResults(int index) const
63 unsigned categoryIndex = static_cast<unsigned>(index);
64 unsigned categoryIndex = static_cast<unsigned>(index);
64 auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
65 auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
65− results->setModel(unity_results->model());
67+ results->setModel(unity_results->model());
69+ // No results model returned by unity core; this can be the case when the global
70+ // results model of this scope became invalid in unity core. Don't set backend
71+ // model in DeeListModel - it will still beahve properly as an empty model. Since
72+ // we're connected to the results model change signal, we'll reset category models
73+ // when results model is set again.
74+ qWarning() << "No results model for category" << categoryIndex;
67 m_results.insert(index, results);
77 m_results.insert(index, results);
@@ -81,6 +91,13 @@ void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
81 setModel(model);
91 setModel(model);
95+void Categories::onScopeResultsModelChanged(unity::glib::Object<DeeModel> /* model */)
97+ // if scope results model changes, we need to reset all category models
98+ onCategoriesModelChanged(m_unityScope->categories()->model());
85Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
102Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
@@ -92,6 +109,9 @@ Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
92 m_categoriesChangedConnection.disconnect();
109 m_categoriesChangedConnection.disconnect();
93 m_categoriesChangedConnection =
110 m_categoriesChangedConnection =
94 m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
111 m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
113+ m_resultshangedConnection.disconnect();
114+ m_resultshangedConnection = m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Categories::onScopeResultsModelChanged));