- if (get_stem (me))
- return first_head (me)->extent (me, X_AXIS);
- else
- {
- // no stems => no suspended noteheads.
- extract_grob_set (me, "note-heads", heads);
- if (heads.size())
- return heads[0]->extent (me, X_AXIS);
- else
- return Interval (0, 0);
- }
+ Grob *main_head = 0;
+ if (get_stem (me))
+ main_head = first_head (me);
+ else
+ {
+ // no stems => no suspended noteheads.
+ extract_grob_set (me, "note-heads", heads);
+ if (heads.size())
+ main_head = heads[0];
+ }
+ Grob *main_item = main_head
+ ? main_head
+ : unsmob<Grob> (me->get_object ("rest"));
+
+ return main_item
+ ? main_item->extent (me, X_AXIS)
+ : Interval (0, 0);