From cb486522a80737e63175e79e841ad31380aa88c3 Mon Sep 17 00:00:00 2001
From: Enrico Turri <enricoturri@seznam.cz>
Date: Wed, 2 May 2018 14:55:17 +0200
Subject: [PATCH] Fixed crash when pressing 'A' with empty print bed

---
 xs/src/libslic3r/Model.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp
index aaea863e8..a43bf0221 100644
--- a/xs/src/libslic3r/Model.cpp
+++ b/xs/src/libslic3r/Model.cpp
@@ -269,6 +269,10 @@ TriangleMesh Model::mesh() const
 
 static bool _arrange(const Pointfs &sizes, coordf_t dist, const BoundingBoxf* bb, Pointfs &out)
 {
+    if (sizes.empty())
+        // return if the list is empty or the following call to BoundingBoxf constructor will lead to a crash
+        return true;
+
     // we supply unscaled data to arrange()
     bool result = Slic3r::Geometry::arrange(
         sizes.size(),               // number of parts