Skip to content

Commit

Permalink
Merge pull request #1625 from ghutchis/selection-crashes
Browse files Browse the repository at this point in the history
Fixed Select Bugs from forum
  • Loading branch information
ghutchis authored Feb 17, 2024
2 parents 36de39b + 2abddda commit 24864c5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions avogadro/qtplugins/select/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,25 @@ void Select::selectAtomIndex()
// check if it's a range
if (item.contains('-')) {
auto range = item.split('-');
if (range.size() >= 2) {
if (range.size() == 2) {
bool ok1, ok2;
int k = m_molecule->atomCount();
int start = range.first().toInt(&ok1);
int last = range.back().toInt(&ok2);
if (ok1 && ok2) {
for (int i = start; i <= last; ++i)
m_molecule->undoMolecule()->setAtomSelected(i, evalSelect(true, i),
undoText);
if (start < k)
for (int i = start; i <= last; ++i)
m_molecule->undoMolecule()->setAtomSelected(
i, evalSelect(true, i), undoText);
}
}
} else {
int i = item.toInt(&ok);
int k = m_molecule->atomCount();
if (ok)
m_molecule->undoMolecule()->setAtomSelected(i, evalSelect(true, i),
undoText);
if (i < k)
m_molecule->undoMolecule()->setAtomSelected(i, evalSelect(true, i),
undoText);
}
}

Expand Down

0 comments on commit 24864c5

Please sign in to comment.