mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Fix crash on removing bookmarks
This commit is contained in:
parent
6ec919e67c
commit
282d88b43f
@ -230,10 +230,14 @@ bool QgsBookmarkManagerModel::removeRows( int row, int count, const QModelIndex
|
||||
{
|
||||
beginRemoveRows( parent, row, row + count );
|
||||
|
||||
QList< QgsBookmark > bookmarks = mManager->bookmarks();
|
||||
QList< QgsBookmark > appBookmarks = mManager->bookmarks();
|
||||
QList< QgsBookmark > projectBookmarks = mProjectManager->bookmarks();
|
||||
for ( int r = row + count - 1; r >= row; --r )
|
||||
{
|
||||
mManager->removeBookmark( bookmarks.at( r ).id() );
|
||||
if ( r >= appBookmarks.count() )
|
||||
mProjectManager->removeBookmark( projectBookmarks.at( r - appBookmarks.size() ).id() );
|
||||
else
|
||||
mManager->removeBookmark( appBookmarks.at( r ).id() );
|
||||
}
|
||||
endRemoveRows();
|
||||
return true;
|
||||
|
@ -235,6 +235,14 @@ class TestQgsBookmarkManagerModel(unittest.TestCase):
|
||||
self.assertEqual([b.name() for b in app_manager.bookmarks()], ['new name', 'new name 2'])
|
||||
self.assertFalse(model.setData(model.index(1, 7), Qt.Unchecked, Qt.CheckStateRole))
|
||||
|
||||
# remove rows
|
||||
model.removeRows(0, 1)
|
||||
self.assertEqual([b.name() for b in project_manager.bookmarks()], ['b2'])
|
||||
self.assertEqual([b.name() for b in app_manager.bookmarks()], ['new name 2'])
|
||||
model.removeRows(0, 2)
|
||||
self.assertEqual([b.name() for b in project_manager.bookmarks()], [])
|
||||
self.assertEqual([b.name() for b in app_manager.bookmarks()], [])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user