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

Fix segfaults in Surfaces and Select Backbone #1031

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions avogadro/qtplugins/select/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,30 +247,20 @@ void Select::selectBackboneAtoms()
selectNone();

for (const auto residue : m_molecule->residues()) {
auto atom = residue.getAtomByName("CA");
if (atom.isValid())
atom.setSelected(evalSelect(true, atom.index()));

atom = residue.getAtomByName("C");
if (atom.isValid())
atom.setSelected(evalSelect(true, atom.index()));

atom = residue.getAtomByName("N");
if (atom.isValid())
atom.setSelected(evalSelect(true, atom.index()));

atom = residue.getAtomByName("O");
if (atom.isValid())
atom.setSelected(evalSelect(true, atom.index()));

// also select hydrogens connected to the backbone atoms
if (atom.atomicNumber() == 1) {
auto bonds = m_molecule->bonds(atom.index());
if (bonds.size() == 1) {
auto otherAtom = bonds[0].getOtherAtom(atom.index());
auto name = residue.getAtomName(otherAtom);
if (name == "CA" || name == "C" || name == "N" || name == "O")
atom.setSelected(evalSelect(true, atom.index()));
for (auto atom : residue.residueAtoms()) {
auto name = residue.getAtomName(atom);
if (name == "CA" || name == "C" || name == "N" || name == "O")
atom.setSelected(evalSelect(true, atom.index()));

// also select hydrogens connected to the backbone atoms
if (atom.atomicNumber() == 1) {
auto bonds = m_molecule->bonds(atom.index());
if (bonds.size() == 1) {
auto otherAtom = bonds[0].getOtherAtom(atom.index());
auto name = residue.getAtomName(otherAtom);
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
if (name == "CA" || name == "C" || name == "N" || name == "O")
atom.setSelected(evalSelect(true, atom.index()));
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions avogadro/qtplugins/surfaces/surfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ void Surfaces::calculateEDT()

// first, make a list of all atom positions and radii
Array<Vector3> atomPositions = m_molecule->atomPositions3d();
auto *atoms =
new std::vector<std::pair<Vector3, double>>(m_molecule->atomCount());
auto *atoms = new std::vector<std::pair<Vector3, double>>();
double max_radius = probeRadius;
QtGui::RWLayerManager layerManager;
for (size_t i = 0; i < m_molecule->atomCount(); i++) {
Expand Down