on xenial help sign in
Added catch for model destroy
c0738cfNick Dedekind
plugins/Unity/Indicators/rootactionstate.cpp+10
@@ -62,6 +62,8 @@ void RootActionState::setMenu(UnityMenuModel* menu)
62 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
62 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
63 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
63 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
64
64
65+ connect(m_menu, SIGNAL(destroyed()), SLOT(reset()));
66+
65 m_menu->setActionStateParser(this);
67 m_menu->setActionStateParser(this);
66 }
68 }
67 updateActionState();
69 updateActionState();
@@ -97,6 +99,14 @@ void RootActionState::onModelDataChanged(const QModelIndex& topLeft, const QMode
97 }
99 }
98}
100}
99
101
102+void RootActionState::reset() {
103+ m_cachedState.clear();
104+ m_menu = NULL;
105+
106+ Q_EMIT menuChanged();
107+ Q_EMIT updated();
108+}
109+
100void RootActionState::updateActionState()
110void RootActionState::updateActionState()
101{
111{
102 if (m_menu && m_menu->rowCount() > 0) {
112 if (m_menu && m_menu->rowCount() > 0) {
plugins/Unity/Indicators/rootactionstate.h+1
@@ -77,6 +77,7 @@ private Q_SLOTS:
77 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
77 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
78 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
78 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
79 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
79 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
80+ void reset();
80
81
81private:
82private:
82 void updateActionState();
83 void updateActionState();