Modify string list in place instead of copying it

Spotted by Coverity scan.
This commit is contained in:
Jean-Marc Lasgouttes 2024-09-29 21:45:08 +02:00
parent a086804eb4
commit 1d64dbf543

View File

@ -317,14 +317,10 @@ void GuiBibtex::relAbsPressed()
QString const new_item = (p == LP_Absolute) QString const new_item = (p == LP_Absolute)
? toqstr(file.relPath(buffer().filePath())) ? toqstr(file.relPath(buffer().filePath()))
: toqstr(file.absoluteFilePath()); : toqstr(file.absoluteFilePath());
QStringList sb; for (QString & s : selected_bibs_) {
for (QString s : selected_bibs_) {
if (s == qf) if (s == qf)
sb << new_item; s = new_item;
else
sb << s;
} }
selected_bibs_ = sb;
setSelectedBibs(selected_bibs_); setSelectedBibs(selected_bibs_);
selectedLV->selectRow(selected_bibs_.indexOf(new_item)); selectedLV->selectRow(selected_bibs_.indexOf(new_item));
changed(); changed();