From bf1229ae46eff7ea0b0e7e94161e38add0c8d1bb Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sun, 17 Nov 2024 22:47:13 -0500 Subject: [PATCH] Fix a potential crash in the new translucent VdW & licorice code The code needed to look up the layers for each atom correctly Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/licorice/licorice.cpp | 4 +++- avogadro/qtplugins/vanderwaals/vanderwaals.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/avogadro/qtplugins/licorice/licorice.cpp b/avogadro/qtplugins/licorice/licorice.cpp index aec6a5dd75..66ef6b672e 100644 --- a/avogadro/qtplugins/licorice/licorice.cpp +++ b/avogadro/qtplugins/licorice/licorice.cpp @@ -124,7 +124,9 @@ void Licorice::process(const Molecule& molecule, Rendering::GroupNode& node) } Vector3ub color = atom.color(); - opacity = m_layerManager.getSetting(i)->opacity; + auto* interface = + m_layerManager.getSetting(m_layerManager.getLayerID(i)); + opacity = interface->opacity; if (opacity < 1.0f) { translucentSpheres->addSphere(atom.position3d().cast(), color, radius, i); diff --git a/avogadro/qtplugins/vanderwaals/vanderwaals.cpp b/avogadro/qtplugins/vanderwaals/vanderwaals.cpp index 2511a6a9e8..ecbcc083b5 100644 --- a/avogadro/qtplugins/vanderwaals/vanderwaals.cpp +++ b/avogadro/qtplugins/vanderwaals/vanderwaals.cpp @@ -121,7 +121,9 @@ void VanDerWaals::process(const QtGui::Molecule& molecule, Vector3ub color = atom.color(); auto radius = static_cast(Elements::radiusVDW(atomicNumber)); - float opacity = m_layerManager.getSetting(i)->opacity; + auto* interface = + m_layerManager.getSetting(m_layerManager.getLayerID(i)); + float opacity = interface->opacity; if (opacity < 1.0f) { translucentSpheres->addSphere(atom.position3d().cast(), color, radius, i);