diff --git a/src/selection.cpp b/src/selection.cpp
index a27e45cb290280da0e57ed6b6fa577c38f156601..82c82b5232c8053dd4eba0f5a0615580b8a0b636 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
NR::Rect Selection::bounds() const
{
GSList const *items = const_cast<Selection *>(this)->itemList();
- if (!items) {
- return NR::Rect(NR::Point(0, 0), NR::Point(0, 0));
- }
-
- GSList const *i = items;
- NR::Rect bbox = sp_item_bbox_desktop(SP_ITEM(i->data));
- GSList const *i_start = i;
- while (i != NULL) {
- if (i != i_start)
- bbox = NR::Rect::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data)));
- i = i->next;
+ NR::Maybe<NR::Rect> bbox = NR::Nothing();
+ for ( GSList const *i = items ; i != NULL ; i = i->next ) {
+ bbox = NR::Rect::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data)));
}
- return bbox;
+ // TODO: return NR::Maybe<NR::Rect>
+ if (bbox) {
+ return *bbox;
+ } else {
+ return NR::Rect(NR::Point(0, 0), NR::Point(0, 0));
+ }
}
NRRect *Selection::boundsInDocument(NRRect *bbox) const {