on xenial help sign in
fix crashes in the mock model
5b58abaLukáš Tinkl
CMakeLists.txt+1−1
@@ -57,7 +57,7 @@ find_package(Qt5DBus 5.4 REQUIRED)
57find_package(Qt5Concurrent 5.4 REQUIRED)
57find_package(Qt5Concurrent 5.4 REQUIRED)
58find_package(Qt5Sql 5.4 REQUIRED)
58find_package(Qt5Sql 5.4 REQUIRED)
59
59
60−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application>=14)
60+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=14)
61pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
61pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+6−11
@@ -90,6 +90,7 @@ QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
90}
90}
91
91
92void MockNotificationModel::append(MockNotification* n) {
92void MockNotificationModel::append(MockNotification* n) {
93+ QQmlEngine::setObjectOwnership(n, QQmlEngine::CppOwnership);
93 int location = m_queue.size();
94 int location = m_queue.size();
94 QModelIndex insertionPoint = QModelIndex();
95 QModelIndex insertionPoint = QModelIndex();
95 beginInsertRows(insertionPoint, location, location);
96 beginInsertRows(insertionPoint, location, location);
@@ -98,9 +99,10 @@ void MockNotificationModel::append(MockNotification* n) {
98}
99}
99
100
100MockNotification* MockNotificationModel::getNotification(int id) const {
101MockNotification* MockNotificationModel::getNotification(int id) const {
101− for(int i=0; i < m_queue.size(); i++) {
102+ for(int i = 0; i < m_queue.size(); i++) {
103+ MockNotification* n = m_queue.at(i);
102− if(m_queue[i]->getID() == id) {
104+ if(n && n->getID() == id) {
103− return m_queue[i];
105+ return n;
104 }
106 }
105 }
107 }
106
108
@@ -130,14 +132,7 @@ void MockNotificationModel::removeInternal(int loc) {
130}
132}
131
133
132MockNotification* MockNotificationModel::getRaw(const int notificationId) const {
134MockNotification* MockNotificationModel::getRaw(const int notificationId) const {
133− for(int i = 0; i < m_queue.size(); i++) {
134− if(m_queue[i]->getID() == notificationId) {
135+ return getNotification(notificationId);
135− MockNotification* n = m_queue[i];
136− return n;
137− }
138− }
139−
140− return nullptr;
141}
136}
142
137
143int MockNotificationModel::queued() const {
138int MockNotificationModel::queued() const {