Skip to content

Commit

Permalink
Fix bookmarks manager model signals emitted twice
Browse files Browse the repository at this point in the history
rows inserted/added was fired twice (once by the manager and once by the
model), confusing the proxy model.

Also count was wrong by 1 in beginInsertRows( parent, oldCount, oldCount + count )
and beginRemoveRows, but now these two calls have been removed completely.

Fix #56493
  • Loading branch information
elpaso authored and nyalldawson committed Mar 27, 2024
1 parent 4a47868 commit b203f78
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/core/qgsbookmarkmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,9 @@ bool QgsBookmarkManagerModel::setData( const QModelIndex &index, const QVariant
return false;
}

bool QgsBookmarkManagerModel::insertRows( int, int count, const QModelIndex &parent )
bool QgsBookmarkManagerModel::insertRows( int, int count, const QModelIndex & )
{
// append
const int oldCount = mManager->bookmarks().count();
beginInsertRows( parent, oldCount, oldCount + count );
bool result = true;
for ( int i = 0; i < count; ++i )
{
Expand All @@ -236,14 +234,11 @@ bool QgsBookmarkManagerModel::insertRows( int, int count, const QModelIndex &par
mBlocked = false;
result &= res;
}
endInsertRows();
return result;
}

bool QgsBookmarkManagerModel::removeRows( int row, int count, const QModelIndex &parent )
bool QgsBookmarkManagerModel::removeRows( int row, int count, const QModelIndex & )
{
beginRemoveRows( parent, row, row + count );

const QList< QgsBookmark > appBookmarks = mManager->bookmarks();
const QList< QgsBookmark > projectBookmarks = mProjectManager->bookmarks();
for ( int r = row + count - 1; r >= row; --r )
Expand All @@ -253,7 +248,6 @@ bool QgsBookmarkManagerModel::removeRows( int row, int count, const QModelIndex
else
mManager->removeBookmark( appBookmarks.at( r ).id() );
}
endRemoveRows();
return true;
}

Expand Down

0 comments on commit b203f78

Please sign in to comment.