From e84ead529197e472f305d7c1d1a6a160fd9fc9a2 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Sat, 4 Jul 2015 15:22:27 +0200
Subject: [PATCH] Bugfix: changing range-based layer heigths didn't trigger
 background processing. #2958

---
 lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
index ce38af97e2..c920b796a1 100644
--- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
+++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
@@ -107,12 +107,17 @@ sub new {
         $grid->SetCellValue($event->GetRow, $event->GetCol, $value);
         
         # if there's no empty row, let's append one
-        for my $i (0 .. $grid->GetNumberRows-1) {
+        for my $i (0 .. $grid->GetNumberRows) {
+            if ($i == $grid->GetNumberRows) {
+                # if we're here then we found no empty row
+                $grid->AppendRows(1);
+                last;
+            }
             if (!grep $grid->GetCellValue($i, $_), 0..2) {
-                return;
+                # exit loop if this row is empty
+                last;
             }
         }
-        $grid->AppendRows(1);
         
         $self->{layers_changed} = 1;
     });