Adjust hydrogens crash

Hi List,

I’m going through the bug tracker today, and came across a crash in
the draw command/adjust hydrogen code. I’m not very familiar with this
code, and the bug is rather unusual, so I’d like to see if anyone here
has any ideas before I dig too deeply.

The bug is here:

https://sourceforge.net/tracker/?func=detail&aid=3463466&group_id=165310&atid=835077

The crash happens after the undo command from the draw tool’s mouse
release event is pushed:

AddAtomDrawCommand_ctor2(element = 1 , adj = QFlags(0x4|0x8) )
AddBondDrawCommand_ctor2(begin = 13 , end = 19 , order = 1 ,
adjBegin = QFlags(0x1|0x2|0x4|0x8) , adjEnd = QFlags(0x2|0x4) )
AddAtomDrawCommand::redo(id = 19 )
AddBondDrawCommand::redo()
AdjustHydrogensPreCommand(atomId = 13 )
AdjustHydrogensPreCommand::redo()
AdjustHydrogensPostCommand()
AdjustHydrogensPostCommand::redo()
AdjustHydrogensPreCommand(atomId = 19 )
<crash…>

I set a breakpoint in
AdjustHydrogensPreCommand::AdjustHydrogensPreCommand(Molecule*, uint
atomId) to try to see what was happening, and found something very
odd:

atomId	19	unsigned long
molecule	0x3084290	Avogadro::Molecule
	m_atomConformers	<1

items> std::vector<std::vector<Eigen::Matrix<double, 3, 1, 2, 3, 1>>*>
m_atomList <20 items> QListAvogadro::Atom*
m_atomPos <21 items> @0x91c690 std::vector<Eigen::Matrix<double, 3,
1, 2, 3, 1>>
m_atoms <21 items> std::vectorAvogadro::Atom*
m_bondList <19 items> QListAvogadro::Bond*
m_bonds <20 items> std::vectorAvogadro::Bond*

The lists and vectors are out of sync. Is this supposed to happen at
this point of the drawing process?

Dave

On Sat, Feb 18, 2012 at 12:26 PM, David Lonie loniedavid@gmail.com wrote:

I set a breakpoint in
AdjustHydrogensPreCommand::AdjustHydrogensPreCommand(Molecule*, uint
atomId) to try to see what was happening, and found something very
odd:

   atomId  19      unsigned long
   molecule        0x3084290       Avogadro::Molecule
           m_atomConformers        <1

items> std::vector<std::vector<Eigen::Matrix<double, 3, 1, 2, 3, 1>>*>
m_atomList <20 items> QListAvogadro::Atom*
m_atomPos <21 items> @0x91c690 std::vector<Eigen::Matrix<double, 3,
1, 2, 3, 1>>
m_atoms <21 items> std::vectorAvogadro::Atom*
m_bondList <19 items> QListAvogadro::Bond*
m_bonds <20 items> std::vectorAvogadro::Bond*

The lists and vectors are out of sync. Is this supposed to happen at
this point of the drawing process?

Also, the atom at index 19 that needs hydrogens adjusted is NULL…

Dave