@@ -90,6 +90,7 @@ QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
9090}
9191
9292void MockNotificationModel::append(MockNotification* n) {
93+ QQmlEngine::setObjectOwnership(n, QQmlEngine::CppOwnership);
9394 int location = m_queue.size();
9495 QModelIndex insertionPoint = QModelIndex();
9596 beginInsertRows(insertionPoint, location, location);
@@ -98,9 +99,10 @@ void MockNotificationModel::append(MockNotification* n) {
9899}
99100
100101MockNotification* MockNotificationModel::getNotification(int id) const {
101− for(int i=0; i < m_queue.size(); i++) {
102− if(m_queue[i]->getID() == id) {
103− return m_queue[i];
102+ for(int i = 0; i < m_queue.size(); i++) {
103+ MockNotification* n = m_queue.at(i);
104+ if(n && n->getID() == id) {
105+ return n;
104106 }
105107 }
106108
@@ -130,14 +132,7 @@ void MockNotificationModel::removeInternal(int loc) {
130132}
131133
132134MockNotification* MockNotificationModel::getRaw(const int notificationId) const {
133− for(int i = 0; i < m_queue.size(); i++) {
134− if(m_queue[i]->getID() == notificationId) {
135− MockNotification* n = m_queue[i];
136− return n;
137− }
138− }
139−
140− return nullptr;
135+ return getNotification(notificationId);
141136}
142137
143138int MockNotificationModel::queued() const {