Fix the contact model using the QAIM API incorrectly. 37
authorRobin Burchell <robin.burchell@collabora.com>
Wed, 21 Sep 2011 12:29:19 +0000 (14:29 +0200)
committerRobin Burchell <robin.burchell@collabora.com>
Wed, 21 Sep 2011 13:49:24 +0000 (15:49 +0200)
commit4d2f6f3de8ba21261d7df272e8100e07e4827d60
treee8659f62ce6dc5722d2014b605ca34914155a3a2
parent635690ea10312fbacfbb332c233b9277ec7aed85
Fix the contact model using the QAIM API incorrectly.

beginInsertRows() takes firstRow, lastRow - not number of rows, so using 'count'
here was incorrect.

beginInsertRows() should also never be invoked for 0 rows, so explicitly check
for no contacts returned.

This caused a crash in the case similar to:

ListView {
    model: ContactModel {
    }
}

Thanks to: Tom Swindell, for finding the bug.
Thanks to: John Brooks, for spotting the cause of this bug.

Reviewed-by: John Brooks
plugins/declarative/contacts/qdeclarativecontactmodel.cpp