From 125054d93676ff6d3f09b827b9b76f3c568b3a61 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 20 Dec 2023 16:41:54 +0100 Subject: [PATCH] Fix SelectorTmp::getAtomCount() w/ selection name (#323) Fixes https://github.com/schrodinger/pymol-open-source/issues/322 --- layer3/Selector.h | 2 +- layer3/SelectorTmp.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/layer3/Selector.h b/layer3/Selector.h index d6d03deb5..d9c76059a 100644 --- a/layer3/Selector.h +++ b/layer3/Selector.h @@ -233,7 +233,7 @@ class SelectorTmp { SelectorFreeTmp(m_G, m_name); } const char * getName() const { return m_name; } - int getAtomCount() { return m_count; } + int getAtomCount(); SelectorID_t getIndex() const { return m_name[0] ? SelectorIndexByName(m_G, m_name, false) : cSelectionInvalid; } diff --git a/layer3/SelectorTmp.cpp b/layer3/SelectorTmp.cpp index 0901680f6..6c778d6e6 100644 --- a/layer3/SelectorTmp.cpp +++ b/layer3/SelectorTmp.cpp @@ -15,6 +15,15 @@ SelectorTmp::SelectorTmp(SelectorTmp&& other) assert(other.m_count == -1); } +int SelectorTmp::getAtomCount() +{ + if (m_count != 0) { + return m_count; + } + + return SelectorCountAtoms(m_G, getIndex(), cSelectorUpdateTableAllStates); +} + /** * Factory which propagates errors. * @param sele Selection expression