From: Vincent Favre-Nicolin <favre@esrf.fr>
Date: Sun, 8 Jan 2023 17:54:19 +0100
Subject: Update lattice parameters from symmetry constraints *before*
 throwing an exception due to angles outside ]0 ; pi[

Bug-Upstream: https://github.com/diffpy/libobjcryst/issues/19
Origin: upstream, https://github.com/diffpy/libobjcryst/commit/8a7643a8fc370d20b790690518c8d7f52c00b5c6
---
 src/ObjCryst/ObjCryst/UnitCell.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/ObjCryst/ObjCryst/UnitCell.cpp b/src/ObjCryst/ObjCryst/UnitCell.cpp
index 1fb1466..bbf2a01 100644
--- a/src/ObjCryst/ObjCryst/UnitCell.cpp
+++ b/src/ObjCryst/ObjCryst/UnitCell.cpp
@@ -354,9 +354,6 @@ void UnitCell::Init(const REAL a, const REAL b, const REAL c, const REAL alpha,
    //mSpaceGroup.Print();
    mSpaceGroup.ChangeSpaceGroup(SpaceGroupId);
    //mSpaceGroup.Print();
-   if((alpha<=0)||(alpha>=M_PI)) throw ObjCrystException("alpha must be within ]0;pi[");
-   if((beta<=0) ||(beta>=M_PI)) throw ObjCrystException("beta must be within ]0;pi[");
-   if((gamma<=0)||(gamma>=M_PI)) throw ObjCrystException("gamma must be within ]0;pi[");
    mCellDim(0)=a;
    mCellDim(1)=b;
    mCellDim(2)=c;
@@ -364,13 +361,16 @@ void UnitCell::Init(const REAL a, const REAL b, const REAL c, const REAL alpha,
    mCellDim(4)=beta;
    mCellDim(5)=gamma;
    mClockLatticePar.Click();
+   this->UpdateLatticePar();
+   if((mCellDim(3)<=0)||(mCellDim(3)>=M_PI)) throw ObjCrystException("alpha must be within ]0;pi[");
+   if((mCellDim(4)<=0)||(mCellDim(4)>=M_PI)) throw ObjCrystException("beta must be within ]0;pi[");
+   if((mCellDim(5)<=0)||(mCellDim(5)>=M_PI)) throw ObjCrystException("gamma must be within ]0;pi[");
 
    mClockMetricMatrix.Reset();
    mClockLatticeParUpdate.Reset();
 
    this->InitRefParList();
    this->InitMatrices();
-   this->UpdateLatticePar();
    this->SetName(name);
 
    VFN_DEBUG_EXIT("UnitCell::Init(a,b,c,alpha,beta,gamma,Sg,name):End",10)
