Skip to content

Commit

Permalink
Check to make sure current calculation index is valid
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 26, 2024
1 parent d74091b commit 1a1cdfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions avogadro/qtplugins/surfaces/orbitals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ void Orbitals::startCalculation(unsigned int queueIndex)

void Orbitals::calculateCube()
{
if (m_currentRunningCalculation == -1)
return;

calcInfo* info = &m_queue[m_currentRunningCalculation];

info->state = Running;
Expand Down Expand Up @@ -341,8 +344,6 @@ void Orbitals::calculateCube()

void Orbitals::calculateCubeDone()
{
calcInfo* info = &m_queue[m_currentRunningCalculation];

auto* watcher = &m_gaussianConcurrent->watcher();
watcher->disconnect(this);

Expand All @@ -354,6 +355,9 @@ void Orbitals::calculateCubeDone()

void Orbitals::calculatePosMesh()
{
if (m_currentRunningCalculation == -1)
return;

calcInfo* info = &m_queue[m_currentRunningCalculation];

info->state = Running;
Expand All @@ -377,6 +381,9 @@ void Orbitals::calculatePosMeshDone()

void Orbitals::calculateNegMesh()
{
if (m_currentRunningCalculation == -1)
return;

calcInfo* info = &m_queue[m_currentRunningCalculation];

info->state = Running;
Expand Down Expand Up @@ -407,6 +414,9 @@ void Orbitals::calculateNegMeshDone()

void Orbitals::calculationComplete()
{
if (m_currentRunningCalculation == -1)
return;

calcInfo* info = &m_queue[m_currentRunningCalculation];

m_dialog->calculationComplete(info->orbital);
Expand Down Expand Up @@ -465,6 +475,9 @@ void Orbitals::renderOrbital(unsigned int row)

void Orbitals::updateProgress(int current)
{
if (m_currentRunningCalculation == -1)
return;

calcInfo* info = &m_queue[m_currentRunningCalculation];
int orbital = info->orbital;
m_dialog->updateProgress(orbital, current);
Expand Down
3 changes: 3 additions & 0 deletions avogadro/qtplugins/surfaces/orbitaltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ QVariant OrbitalTableModel::data(const QModelIndex& index, int role) const
int stages = (orb->totalStages == 0) ? 1 : orb->totalStages;
percent /= float(stages);
percent += (orb->stage - 1) * (100.0 / float(stages));
// clamp to 100%
if (percent > 100)
percent = 100;
return QString("%L1 %").arg(percent);
}
case C_Symmetry:
Expand Down

1 comment on commit 1a1cdfa

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.

Please sign in to comment.