From 27f01bb09e98895c1a56bb946e380f049d2c1f84 Mon Sep 17 00:00:00 2001
From: Enrico Turri <enricoturri@seznam.cz>
Date: Tue, 10 Sep 2019 11:16:59 +0200
Subject: [PATCH] Fixed instance printable property after reload from disk

---
 src/libslic3r/Model.hpp   |  2 +-
 src/slic3r/GUI/Plater.cpp | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp
index 422467e08..19f032b1c 100644
--- a/src/libslic3r/Model.hpp
+++ b/src/libslic3r/Model.hpp
@@ -674,7 +674,7 @@ private:
     explicit ModelInstance(ModelObject* object) : print_volume_state(PVS_Inside), printable(true), object(object) { assert(this->id().valid()); }
     // Constructor, which assigns a new unique ID.
     explicit ModelInstance(ModelObject *object, const ModelInstance &other) :
-        m_transformation(other.m_transformation), print_volume_state(PVS_Inside), printable(true), object(object) {assert(this->id().valid() && this->id() != other.id());}
+        m_transformation(other.m_transformation), print_volume_state(PVS_Inside), printable(other.printable), object(object) { assert(this->id().valid() && this->id() != other.id()); }
 
     explicit ModelInstance(ModelInstance &&rhs) = delete;
     ModelInstance& operator=(const ModelInstance &rhs) = delete;
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index db8a52e17..0b309891c 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -3106,6 +3106,7 @@ void Plater::priv::reload_from_disk()
     for (const auto idx : new_idxs) {
         ModelObject *object = model.objects[idx];
         object->config.apply(object_orig->config);
+
         object->clear_instances();
         for (const ModelInstance *instance : object_orig->instances) {
             object->add_instance(*instance);
@@ -3117,14 +3118,26 @@ void Plater::priv::reload_from_disk()
             }
         }
 
-        if (object_orig->instances.size() > 1)
-            sidebar->obj_list()->increase_object_instances(idx, object_orig->instances.size());
+        if (object->instances.size() > 1)
+        {
+            sidebar->obj_list()->increase_object_instances(idx, object->instances.size());
+            for (int i = 0; i < (int)object->instances.size(); ++i)
+            {
+                sidebar->obj_list()->update_printable_state((int)idx, i);
+            }
+        }
 
         // XXX: Restore more: layer_height_ranges, layer_height_profile (?)
     }
 
     remove(obj_orig_idx);
 
+    // new GLVolumes have been created at this point, so update their printable state
+    for (size_t i = 0; i < model.objects.size(); ++i)
+    {
+        view3D->get_canvas3d()->update_instance_printable_state_for_object(i);
+    }
+
     // re-enable render 
     view3D->get_canvas3d()->enable_render(true);