Skip to content

Commit

Permalink
App crashes when clicking "Optimize Geometry" without any atom (#1661)
Browse files Browse the repository at this point in the history
* Add a check to prevent a crash when no atoms are found

Signed-off-by: Perminder Singh <[email protected]>

---------

Signed-off-by: Perminder <[email protected]>
Signed-off-by: Perminder Singh <[email protected]>
  • Loading branch information
perminder-17 authored Jun 26, 2024
1 parent 8055bbb commit e3be193
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions avogadro/qtplugins/forcefield/forcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ void Forcefield::optimize()
if (m_molecule == nullptr || m_method == nullptr)
return;

if (!m_molecule->atomCount()) {
QMessageBox::information(nullptr, tr("Avogadro"),
tr("No atoms provided for optimization"));
return;
}

// merge all coordinate updates into one step for undo
bool isInteractive = m_molecule->undoMolecule()->isInteractive();
m_molecule->undoMolecule()->setInteractive(true);
Expand Down

0 comments on commit e3be193

Please sign in to comment.