on xenial help sign in
don't emit pinnedChanged if it actually doesn't unpin, update test
commita06033406ed73dde7822c00eeb3a5131992e2fa6 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 21 Oct 2014, 22:24 (12 years ago) parent6e14238
2 files changed+8−5
plugins/Unity/Launcher/launchermodel.cpp+5−3 tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−2
plugins/Unity/Launcher/launchermodel.cpp+5−3
@@ -281,9 +281,11 @@ void LauncherModel::unpin(const QString &appId)
281281 }
282282
283283 if (m_appManager->findApplication(appId)) {
284− m_list.at(index)->setPinned(false);
285− QModelIndex modelIndex = this->index(index);
286− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
284+ if (m_list.at(index)->pinned()) {
285+ m_list.at(index)->setPinned(false);
286+ QModelIndex modelIndex = this->index(index);
287+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
288+ }
287289 } else {
288290 beginRemoveRows(QModelIndex(), index, index);
289291 m_list.takeAt(index)->deleteLater();
tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−2
@@ -186,6 +186,7 @@ private Q_SLOTS:
186186 QCOMPARE(spy.count() > 0, true);
187187 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
188188
189+ // App should be pinned now
189190 spy.clear();
190191 launcherModel->requestRemove(launcherModel->get(0)->appId());
191192 QCOMPARE(launcherModel->get(0)->pinned(), false);
@@ -193,12 +194,12 @@ private Q_SLOTS:
193194 QCOMPARE(spy.count(), 1);
194195 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
195196
197+ // Now that the app is unpinned, nothing should change, but the signal shouldn't be emitted
196198 spy.clear();
197199 launcherModel->requestRemove(launcherModel->get(0)->appId());
198200 QCOMPARE(launcherModel->get(0)->pinned(), false);
199201 QCOMPARE(launcherModel->get(1)->pinned(), false);
200− QCOMPARE(spy.count(), 1);
201− QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
202+ QCOMPARE(spy.count(), 0);
202203 }
203204
204205 void testRemove_data() {