From e62672f787dbb680a050e33454fe29efa3729af6 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Mon, 26 May 2014 13:10:58 +0200
Subject: [PATCH] Fix regression in Split from GUI. Might be related to #1998

---
 lib/Slic3r/GUI/Plater.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 84e17ebe9..a2750193e 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -627,12 +627,6 @@ sub split_object {
         Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be split because it already contains a single part.");
         return;
     }
-
-    # remove the original object before spawning the object_loaded event, otherwise 
-    # we'll pass the wrong $obj_idx to it (which won't be recognized after the
-    # thumbnail thread returns)
-    $self->remove($obj_idx);
-    $current_object = $obj_idx = undef;
     
     # create a bogus Model object, we only need to instantiate the new Model::Object objects
     my $new_model = Slic3r::Model->new;
@@ -666,6 +660,12 @@ sub split_object {
         $model_object->center_around_origin;
         push @model_objects, $model_object;
     }
+
+    # remove the original object before spawning the object_loaded event, otherwise 
+    # we'll pass the wrong $obj_idx to it (which won't be recognized after the
+    # thumbnail thread returns)
+    $self->remove($obj_idx);
+    $current_object = $obj_idx = undef;
     
     # load all model objects at once, otherwise the plate would be rearranged after each one
     # causing original positions not to be kept