diff --git a/avogadro/qtplugins/copypaste/copypaste.cpp b/avogadro/qtplugins/copypaste/copypaste.cpp index 379105a587..6b17ff1adc 100644 --- a/avogadro/qtplugins/copypaste/copypaste.cpp +++ b/avogadro/qtplugins/copypaste/copypaste.cpp @@ -13,12 +13,11 @@ #include -#include #include +#include #include #include - #include #include @@ -113,7 +112,8 @@ void CopyPaste::copyInChI() bool CopyPaste::copy(Io::FileFormat* format) { - if (!m_molecule) + if (m_molecule == nullptr || m_molecule->atomCount() == 0 || + format == nullptr) return false; std::string output; @@ -197,6 +197,9 @@ void CopyPaste::cut() void CopyPaste::clear() { + if (m_molecule == nullptr || m_molecule->atomCount() == 0) + return; + if (m_molecule->isSelectionEmpty()) m_molecule->undoMolecule()->clearAtoms(); else {