aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-02-15 11:08:09 +0100
committerThomas White <taw@physics.org>2013-02-15 11:08:09 +0100
commitd93ce840a5110d8f4d79e19ca06200106e7b5bea (patch)
tree2ec096f9512be74eb7c33c3ea453935086691c74
parent9b4ab9508f4721c19f58c5f29dbe47736602fd12 (diff)
Check for lattice type should be done before calling match_cell()
-rw-r--r--libcrystfel/src/mosflm.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c
index 0e00993a..8b86f72c 100644
--- a/libcrystfel/src/mosflm.c
+++ b/libcrystfel/src/mosflm.c
@@ -129,26 +129,8 @@ static int check_cell(struct mosflm_private *mp, struct image *image,
UnitCell *out;
Crystal *cr;
- if ( mp->indm & INDEXING_CHECK_CELL_COMBINATIONS ) {
-
- out = match_cell(cell, mp->template, 0, mp->ltl, 1);
- if ( out == NULL ) return 0;
-
- } else if ( mp->indm & INDEXING_CHECK_CELL_AXES ) {
-
- out = match_cell(cell, mp->template, 0, mp->ltl, 0);
- if ( out == NULL ) return 0;
-
- } else {
- out = cell_new_from_cell(cell);
- }
-
- cr = crystal_new();
- if ( cr == NULL ) {
- ERROR("Failed to allocate crystal.\n");
- return 0;
- }
-
+ /* If we sent lattice information, make sure that we got back what we
+ * asked for, not (e.g.) some "H" version of a rhombohedral R cell */
if ( mp->indm & INDEXING_USE_LATTICE_TYPE ) {
LatticeType latt_m, latt_r;
@@ -159,14 +141,13 @@ static int check_cell(struct mosflm_private *mp, struct image *image,
cen_r = cell_get_centering(mp->template);
/* What we got back */
- latt_m = cell_get_lattice_type(out);
- cen_m = cell_get_centering(out);
+ latt_m = cell_get_lattice_type(cell);
+ cen_m = cell_get_centering(cell);
if ( latt_r != latt_m ) {
ERROR("Lattice type produced by MOSFLM (%i) does not "
"match what was requested (%i). "
"Please report this.\n", latt_m, latt_r);
- crystal_free(cr);
return 0;
}
@@ -174,17 +155,37 @@ static int check_cell(struct mosflm_private *mp, struct image *image,
ERROR("Centering produced by MOSFLM (%c) does not "
"match what was requested (%c). "
"Please report this.\n", cen_m, cen_r);
- crystal_free(cr);
return 0;
}
}
+ if ( mp->indm & INDEXING_CHECK_CELL_COMBINATIONS ) {
+
+ out = match_cell(cell, mp->template, 0, mp->ltl, 1);
+ if ( out == NULL ) return 0;
+
+ } else if ( mp->indm & INDEXING_CHECK_CELL_AXES ) {
+
+ out = match_cell(cell, mp->template, 0, mp->ltl, 0);
+ if ( out == NULL ) return 0;
+
+ } else {
+ out = cell_new_from_cell(cell);
+ }
+
+ cr = crystal_new();
+ if ( cr == NULL ) {
+ ERROR("Failed to allocate crystal.\n");
+ return 0;
+ }
+
crystal_set_cell(cr, out);
if ( mp->indm & INDEXING_CHECK_PEAKS ) {
if ( !peak_sanity_check(image, &cr, 1) ) {
- crystal_free(cr); /* Frees the cell as well */
+ cell_free(out);
+ crystal_free(cr);
return 0;
}
}
@@ -320,6 +321,8 @@ static int read_newmat(struct mosflm_data *mosflm, const char *filename,
mosflm->done = 1;
}
+ cell_free(cell);
+
return 0;
}