Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unselected atoms become selected (and vice versa) when other atoms are deleted #650

Closed
drew-parsons opened this issue Jul 6, 2021 · 5 comments · Fixed by #672
Closed

Comments

@drew-parsons
Copy link
Contributor

**Avogadro version: 1.94.0-371-g7479d2e **

  • Avogadrolibs: 1.9.4
  • Qt: 5.15.2

**Desktop version: **

  • OS: Debian GNU/Linux]
  • Version linux 5.10.46 (debian unstable)
  • Compiler g++ 10.2.1

Describe the bug

When some atoms in a molecule are selected, and other atoms are then deleted, some of the selected atoms become deselected.

Conversely if some selected atoms are deleted, then some previously deselected atoms suddenly become selected.

My guess is that the list of selected atoms is a list of indices to the atoms in the molecule, and is not refreshed when the lists of atoms in the molecule changes (e,g, by deletion).

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple ethane molecule

  2. Click on Selection Tool and select the right-most methyl
    Screenshot from 2021-07-06 16-41-20

  3. Select Build [pencil] tool

  4. Delete (right-click) one of the unselected hydrogens on the left. That hydrogen disappears, but one of the hydrogens on the right becomes deselected.
    Screenshot from 2021-07-06 16-38-59

Conversely,
2'. Click on Selection Tool and select the left-most methyl
Screenshot from 2021-07-06 16-31-23

4'. Delete (right-click) one of the selected hydrogens on the left. That hydrogen disappears, but one of the hydrogens on the right becomes selected.
Screenshot from 2021-07-06 16-31-44

Expected behavior

Previously deselected atoms should not suddenly become selected when atoms are removed (or added).
Previously selected atoms should not suddenly become deselected when atoms are removed (or added) (or alternatively the entire selection should get cleared).

@avo-bot
Copy link

avo-bot commented Jul 10, 2021

This issue has been mentioned on Avogadro Discussion. There might be relevant details there:

https://discuss.avogadro.cc/t/avogadro-1-94-when-deleting-multiple-selected-atoms-other-atoms-become-selected/3567/2

ghutchis added a commit to ghutchis/avogadrolibs that referenced this issue Jul 14, 2021
Two bugs in one - selected items weren't updated by Molecule class
and atoms were removed in a bad order. (Remove in reverse to keep
Index correct)

Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
@ghutchis ghutchis linked a pull request Jul 14, 2021 that will close this issue
@github-actions
Copy link
Contributor

Here are the build results
macOS.dmg
Ubuntu-2004.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

@ghutchis
Copy link
Member

@drew-parsons @mquevill - as far as I can tell, the patch fixes the problem...

@drew-parsons
Copy link
Contributor Author

The patch looks like it's making the right corrections. The codebase has diverged from 1.94.0 now so I can't apply and test so easily as a single patch.

ghutchis added a commit that referenced this issue Jul 16, 2021
ghutchis added a commit to ghutchis/avogadrolibs that referenced this issue Jul 16, 2021
Bug raised by @mquevill - delete a non-selected atom

Since deleting atoms renumbers, make sure selected atoms stays
with "swap and pop" form from atom index, etc.

Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
@github-actions
Copy link
Contributor

Here are the build results
macOS.dmg
Ubuntu-2004.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

ghutchis added a commit that referenced this issue Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants