diff --git a/src/selection.cpp b/src/selection.cpp
index c6b307c3b0ddd0918411f374e2852f560e0988ed..201661eecc89345575aede6f4195c8ce66ef1efb 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
std::vector<NR::Point> Selection::getSnapPointsConvexHull() const {
GSList const *items = const_cast<Selection *>(this)->itemList();
+
std::vector<NR::Point> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p));
}
- std::vector<NR::Point>::iterator i;
- NR::ConvexHull cvh(*(p.begin()));
- for (i = p.begin(); i != p.end(); i++) {
- // these are the points we get back
- cvh.add(*i);
- }
+ std::vector<NR::Point> pHull;
+ if (!p.empty()) {
+ std::vector<NR::Point>::iterator i;
+ NR::ConvexHull cvh(p.front());
+ for (i = p.begin(); i != p.end(); i++) {
+ // these are the points we get back
+ cvh.add(*i);
+ }
- NR::Rect rHull = cvh.bounds();
- std::vector<NR::Point> pHull(4);
- pHull[0] = rHull.corner(0);
- pHull[1] = rHull.corner(1);
- pHull[2] = rHull.corner(2);
- pHull[3] = rHull.corner(3);
+ NR::Maybe<NR::Rect> rHull = cvh.bounds();
+ if (rHull) {
+ for ( unsigned i = 0 ; i < 4 ; ++i ) {
+ pHull.push_back(rHull->corner(i));
+ }
+ }
+ }
return pHull;
}