Closed pavoljuhas closed 5 years ago
Ok, I'll trust your changes. See that indeed now checking for a null pointer (mpCCTbxSpaceGroup!=0) before deleting is unnecessary.
@vincefn - Sorry I found an error. Could you please also merge a38c06e0efe8eda306e201decb295062d8748b7f, i.e.,
git pull https://github.com/pavoljuhas/objcryst.git fix-spacegroup-recursion
I found the changes broke reading of CIF files, because CreateCrystalFromCIF checks several space group origins, which may now throw exception. I have added exception handling in a38c06e0efe8eda306e201decb295062d8748b7f and the pyobjcryst tests are passing now - see https://github.com/diffpy/pyobjcryst/pull/22
Let me know if I should open a new PR.
It will be easier if you submit a PR, yes- Thanks
Sure. I have noticed one more thing - ObjCrystException writes out the ObjCryst++ state to an xml file, but now this happens within a successful CreateCrystalFromCIF call. I can think of several ways how to fix that:
__DEBUG__
macroObjCrystException::verbose = false
in CIF reader to suppresses XMLSpaceGroup("bad")
say invalid_argument
which would avoid the XML issueWhat would be your preference? I suppose 3 might be the easiest.
3 sounds better- I know writing the xml when an exception is caught is quite ugly as too many things can go wrong, it's mostly a desperate recovery attempt when soothing goes wrong within Fox...
Fix segfault due to infinite recursion from
SpaceGroup("invalid")
. Throw ObjCrystException for invalid SG name in constructor andChangeSpaceGroup
.I am not sure we need the second try-catch guard, because at that point the
mpCCTbxSpaceGroup
exists. Perhaps that try-catch guard can be removedI am attaching two example source files to test the behavior with invalid SG names.
tsg1.cpp.txt - test constructor tsg2.cpp.txt - test ChangeSpaceGroup