From e2aae39f151edc5e77054288a95ecd8a8f382bf3 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Fri, 18 Mar 2016 01:15:52 +0100
Subject: [PATCH] Bugfix: crash when input to bed shape options was '-'. #3254

---
 lib/Slic3r/GUI/BedShapeDialog.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/Slic3r/GUI/BedShapeDialog.pm b/lib/Slic3r/GUI/BedShapeDialog.pm
index deae8327e..ee794a261 100644
--- a/lib/Slic3r/GUI/BedShapeDialog.pm
+++ b/lib/Slic3r/GUI/BedShapeDialog.pm
@@ -41,6 +41,7 @@ sub GetValue {
 package Slic3r::GUI::BedShapePanel;
 
 use List::Util qw(min max sum first);
+use Scalar::Util qw(looks_like_number);
 use Slic3r::Geometry qw(PI X Y scale unscale scaled_epsilon deg2rad);
 use Wx qw(:font :id :misc :sizer :choicebook :filedialog :pen :brush wxTAB_TRAVERSAL);
 use Wx::Event qw(EVT_CLOSE EVT_CHOICEBOOK_PAGE_CHANGED EVT_BUTTON);
@@ -189,12 +190,12 @@ sub _update_shape {
         my $rect_size = $self->{optgroups}[SHAPE_RECTANGULAR]->get_value('rect_size');
         my $rect_origin = $self->{optgroups}[SHAPE_RECTANGULAR]->get_value('rect_origin');
         my ($x, $y) = @$rect_size;
-        return if !$x || !$y;  # empty strings
+        return if !looks_like_number($x) || !looks_like_number($y);  # empty strings or '-' or other things
         my ($x0, $y0) = (0,0);
         my ($x1, $y1) = ($x,$y);
         {
             my ($dx, $dy) = @$rect_origin;
-            return if $dx eq '' || $dy eq '';  # empty strings
+            return if !looks_like_number($dx) || !looks_like_number($dy);  # empty strings or '-' or other things
             $x0 -= $dx;
             $x1 -= $dx;
             $y0 -= $dy;