on xenial help sign in
Added catch for model destroy
commitc0738cff488f51577072cfda6afa5c219c72ebfc authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 11 Oct 2013, 15:32 (13 years ago) parent1bfad40
2 files changed+11
plugins/Unity/Indicators/rootactionstate.cpp+10 plugins/Unity/Indicators/rootactionstate.h+1
plugins/Unity/Indicators/rootactionstate.cpp+10
@@ -62,6 +62,8 @@ void RootActionState::setMenu(UnityMenuModel* menu)
6262 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
6363 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
6464
65+ connect(m_menu, SIGNAL(destroyed()), SLOT(reset()));
66+
6567 m_menu->setActionStateParser(this);
6668 }
6769 updateActionState();
@@ -97,6 +99,14 @@ void RootActionState::onModelDataChanged(const QModelIndex& topLeft, const QMode
9799 }
98100}
99101
102+void RootActionState::reset() {
103+ m_cachedState.clear();
104+ m_menu = NULL;
105+
106+ Q_EMIT menuChanged();
107+ Q_EMIT updated();
108+}
109+
100110void RootActionState::updateActionState()
101111{
102112 if (m_menu && m_menu->rowCount() > 0) {
plugins/Unity/Indicators/rootactionstate.h+1
@@ -77,6 +77,7 @@ private Q_SLOTS:
7777 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
7878 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
7979 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
80+ void reset();
8081
8182private:
8283 void updateActionState();