Skip to content

Commit 5f6e34f

Browse files
authored
Merge pull request #42 from pavoljuhas/fix-spacegroup-recursion
Fix spacegroup recursion
2 parents 5e73d32 + 1dadd87 commit 5f6e34f

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

ObjCryst/ObjCryst/SpaceGroup.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -581,27 +581,29 @@ void SpaceGroup::InitSpaceGroup(const string &spgId)
581581
#endif
582582
try
583583
{
584+
// replace mpCCTbxSpaceGroup only after we get new space group
584585
cctbx::sgtbx::space_group_symbols sgs=cctbx::sgtbx::space_group_symbols(spgId);
585-
if(mpCCTbxSpaceGroup!=0) delete mpCCTbxSpaceGroup;
586-
mpCCTbxSpaceGroup=0;
587-
mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group(sgs);
586+
cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group(sgs);
587+
assert(nsg);
588+
delete mpCCTbxSpaceGroup;
589+
mpCCTbxSpaceGroup = nsg;
588590
}
589-
catch(exception &ex1)
591+
catch(cctbx::error ex1)
590592
{
591593
try
592594
{
593-
(*fpObjCrystInformUser)("Failed lookup symbol ! try Hall symbol ?");
594-
if(mpCCTbxSpaceGroup!=0) delete mpCCTbxSpaceGroup;
595-
mpCCTbxSpaceGroup=0;
596-
mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group(spgId);
595+
(*fpObjCrystInformUser)("Lookup of '" + spgId + "' symbol failed, trying as Hall symbol.");
596+
// replace mpCCTbxSpaceGroup only after we get new space group
597+
cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group(spgId);
598+
assert(nsg);
599+
delete mpCCTbxSpaceGroup;
600+
mpCCTbxSpaceGroup = nsg;
597601
}
598-
catch(exception &ex2)
602+
catch(cctbx::error ex2)
599603
{
600604
(*fpObjCrystInformUser)("Could not interpret Spacegroup Symbol:"+spgId);
601-
(*fpObjCrystInformUser)("Reverting to spacegroup symbol:"+mId);
602-
this->InitSpaceGroup(mId);
603-
VFN_DEBUG_EXIT("SpaceGroup::InitSpaceGroup() could not interpret spacegroup:"<<spgId<<":"<<ex1.what()<<":"<<ex2.what(),8)
604-
return;
605+
string emsg = "Space group symbol '" + spgId + "' not recognized";
606+
throw ObjCrystException(emsg);
605607
}
606608
}
607609

@@ -642,13 +644,17 @@ void SpaceGroup::InitSpaceGroup(const string &spgId)
642644

643645
mExtension='\0'; //this->GetCCTbxSpg().type().extension();
644646
}
645-
catch(exception &ex)
647+
catch(cctbx::error ex)
646648
{
647649
(*fpObjCrystInformUser)("Error initializing spacegroup (Incorrect Hall symbol ?):"+spgId);
648-
this->InitSpaceGroup(mId);
649-
(*fpObjCrystInformUser)("Reverting to spacegroup symbol:"+mId);
650+
if (mId != spgId)
651+
{
652+
(*fpObjCrystInformUser)("Reverting to spacegroup symbol:"+mId);
653+
this->InitSpaceGroup(mId);
654+
}
650655
VFN_DEBUG_EXIT("SpaceGroup::InitSpaceGroup() could not interpret spacegroup:"<<spgId<<":"<<ex.what(),8)
651-
return;
656+
string emsg = "Space group symbol '" + spgId + "' not recognized";
657+
throw ObjCrystException(emsg);
652658
}
653659

654660
mExtension=this->GetCCTbxSpg().match_tabulated_settings().extension();

0 commit comments

Comments
 (0)