- {
- extract_grob_set (c, "right-neighbors", rns_arr);
- extract_grob_set (c, "left-neighbors", lns_arr);
-
- SCM lns = lns_arr.size () ? lns_arr.back ()->self_scm () : SCM_BOOL_F;
- SCM rns = rns_arr.size () ? rns_arr.back ()->self_scm () : SCM_BOOL_F;
-
- /*
- Either object can be non existent, if the score ends
- prematurely.
- */
-
- extract_grob_set (unsmob_grob (rns), "right-items", right_items);
- if (right_items.size () == 0 || !unsmob_grob (lns))
- {
- c->programming_error ("Cannot determine neighbors for floating column. ");
- c->set_object ("between-cols", scm_cons (cols->at (i-1)->self_scm (),
- cols->at (i+1)->self_scm ()));
- }
- else
- {
- Grob *min_item = 0;
- int min_rank = INT_MAX;
- for (vsize j = 0; j < right_items.size (); j ++)
- {
- int rank = dynamic_cast<Item*> (right_items[j])->get_column ()->get_rank ();
- if (rank < min_rank)
- {
- min_item = right_items[j];
- min_rank = rank;
- }
- }
-
- c->set_object ("between-cols", scm_cons (lns,
- min_item->self_scm ()));
-
- /*
- Set distance constraints for loose columns
- */
- Drul_array<Item *> next_door (dynamic_cast<Item*> (cols->at (i - 1)),
- dynamic_cast<Item*> (cols->at (i + 1)));
-
- set_distances_for_loose_col (me, c, next_door, options);
- }
- }
-
- if (!loose)
- newcols.push_back (c);
+ {
+ Grob *right_neighbor = unsmob<Grob> (c->get_object ("right-neighbor"));
+ Grob *left_neighbor = unsmob<Grob> (c->get_object ("left-neighbor"));
+
+ /*
+ Either object can be non existent, if the score ends
+ prematurely.
+ */
+ if (!right_neighbor || !left_neighbor)
+ {
+ c->programming_error ("Cannot determine neighbors for floating column.");
+ c->set_object ("between-cols", scm_cons (cols->at (i - 1)->self_scm (),
+ cols->at (i + 1)->self_scm ()));
+ }
+ else
+ {
+ c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (),
+ right_neighbor->self_scm ()));
+
+ /*
+ Set distance constraints for loose columns
+ */
+ Drul_array<Item *> next_door (dynamic_cast<Item *> (left_neighbor),
+ dynamic_cast<Item *> (right_neighbor));
+
+ set_distances_for_loose_col (me, c, next_door, options);
+ }
+ }
+
+ else
+ newcols.push_back (c);