Skip to content

Commit

Permalink
Ensure on removal of share that display string is updated for last (n…
Browse files Browse the repository at this point in the history
…ow non-)duplicate share

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra authored and mgallien committed Oct 18, 2024
1 parent cd1d1f5 commit e366042
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/gui/filedetails/sharemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,26 @@ void ShareModel::slotRemoveShareWithId(const QString &shareId)
const auto sharee = share->getShareWith();
slotRemoveSharee(sharee);

beginRemoveRows({}, shareIndex.row(), shareIndex.row());
_shares.removeAt(shareIndex.row());
const auto shareRow = shareIndex.row();
beginRemoveRows({}, shareRow, shareRow);
_shares.removeAt(shareRow);
endRemoveRows();

// Handle display name duplicates now. First remove the index from the bucket it was in; then,
// check if this removal means the remaining index in the bucket is no longer a duplicate.
// If this is the case then handle the update for this item too.
const auto duplicateShares = _duplicateDisplayNameShareIndices.value(shareRow);
if (duplicateShares) {
duplicateShares->remove(shareRow);
if (duplicateShares->count() == 1) {
const auto noLongerDuplicateIndex = *(duplicateShares->begin());
_duplicateDisplayNameShareIndices.remove(noLongerDuplicateIndex);
const auto noLongerDuplicateModelIndex = index(noLongerDuplicateIndex);
Q_EMIT dataChanged(noLongerDuplicateModelIndex, noLongerDuplicateModelIndex, {Qt::DisplayRole});

Check warning on line 665 in src/gui/filedetails/sharemodel.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/sharemodel.cpp:665:20 [cppcoreguidelines-init-variables]

variable 'dataChanged' is not initialized
}
_duplicateDisplayNameShareIndices.remove(shareRow);
}

handleLinkShare();

Q_EMIT sharesChanged();
Expand Down

0 comments on commit e366042

Please sign in to comment.