diff --git a/api/tests/integration/ref/formats/mol_features.py.out b/api/tests/integration/ref/formats/mol_features.py.out index adde2a4d47..af0b7d5236 100644 --- a/api/tests/integration/ref/formats/mol_features.py.out +++ b/api/tests/integration/ref/formats/mol_features.py.out @@ -13075,3 +13075,5 @@ M V30 END SGROUP M V30 END CTAB M END +*** 1431 Query explicit valency crash *** +[#6;+2;v;D0;$([*,#1]=,#,:[*,#1]);x0]1=[#6]-[#6]=[#6]-[#6]=[#6]-1.[#6]-[#6]-[#6@@](-[#6])-[#6]-[#6] diff --git a/api/tests/integration/tests/formats/mol_features.py b/api/tests/integration/tests/formats/mol_features.py index d1ece98bce..46fd17d922 100644 --- a/api/tests/integration/tests/formats/mol_features.py +++ b/api/tests/integration/tests/formats/mol_features.py @@ -176,3 +176,10 @@ def printGroupsInfo(m): print(smiles) indigo.setOption("molfile-saving-mode", "3000") print(mol.molfile()) + +print("*** 1431 Query explicit valency crash ***") +qmol = indigo.loadQueryMoleculeFromFile( + joinPathPy("molecules/query_crash_1431.mol", __file__) +) + +print(qmol.smarts()) diff --git a/api/tests/integration/tests/formats/molecules/query_crash_1431.mol b/api/tests/integration/tests/formats/molecules/query_crash_1431.mol new file mode 100644 index 0000000000..7ccf95082f --- /dev/null +++ b/api/tests/integration/tests/formats/molecules/query_crash_1431.mol @@ -0,0 +1,38 @@ + + SMMXDraw07231311392D + + 0 0 0 0 0 999 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 12 11 0 0 0 +M V30 BEGIN ATOM +M V30 1 C 12.4156 -5.7104 0 0 CHG=2 VAL=1 INVRET=2 SUBST=-1 UNSAT=1 RBCNT=-2 +M V30 2 C 13.7493 -6.4805 0 0 +M V30 3 C 13.7493 -8.0205 0 0 +M V30 4 C 12.4156 -8.7905 0 0 +M V30 5 C 11.082 -8.0205 0 0 +M V30 6 C 11.082 -6.4805 0 0 +M V30 7 C 3.8438 -5.3438 0 0 +M V30 8 C 4.703 -5.8398 0 0 +M V30 9 C 5.5622 -5.3438 0 0 CFG=2 +M V30 10 C 6.4214 -5.8398 0 0 +M V30 11 C 7.2806 -5.3438 0 0 +M V30 12 C 5.5622 -4.3516 0 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 2 2 3 +M V30 3 1 3 4 +M V30 4 2 4 5 +M V30 5 1 5 6 +M V30 6 2 6 1 +M V30 7 1 7 8 +M V30 8 1 8 9 +M V30 9 1 9 10 +M V30 10 1 10 11 +M V30 11 1 9 12 CFG=1 +M V30 END BOND +M V30 BEGIN COLLECTION +M V30 MDLV30/STEREL1 ATOMS=(1 9) +M V30 END COLLECTION +M V30 END CTAB +M END diff --git a/core/indigo-core/molecule/src/query_molecule.cpp b/core/indigo-core/molecule/src/query_molecule.cpp index 34f8a3411c..4d5c8074b9 100644 --- a/core/indigo-core/molecule/src/query_molecule.cpp +++ b/core/indigo-core/molecule/src/query_molecule.cpp @@ -1855,7 +1855,8 @@ QueryMolecule::Atom* QueryMolecule::releaseAtom(int idx) void QueryMolecule::resetAtom(int idx, QueryMolecule::Atom* atom) { - _atoms.reset(idx); + if (atom != _atoms[idx]) + _atoms.reset(idx); _atoms[idx] = atom; updateEditRevision(); }