From f1f68cfd85d4bee7e0f2248965ef342f673f6649 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Wed, 6 Mar 2019 09:28:55 +0100
Subject: [PATCH 1/3] Fixed a crash after a printer preset changing with
 selected setting's item in an object list

---
 src/slic3r/GUI/GUI_ObjectList.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp
index a961c9ffa..44998c14f 100644
--- a/src/slic3r/GUI/GUI_ObjectList.cpp
+++ b/src/slic3r/GUI/GUI_ObjectList.cpp
@@ -2147,7 +2147,15 @@ void ObjectList::update_settings_items()
     for (auto& item : items) {        
         const wxDataViewItem& settings_item = m_objects_model->GetSettingsItem(item);
         select_item(settings_item ? settings_item : m_objects_model->AddSettingsChild(item));
+
+        // If settings item was deleted from the list, 
+        // it's need to be deleted from selection array, if it was there
+        if (settings_item != m_objects_model->GetSettingsItem(item) && 
+            sel.Index(settings_item) != wxNOT_FOUND) {
+            sel.Remove(settings_item);
+        }
     }
+
     // restore selection:
     SetSelections(sel);
     m_prevent_canvas_selection_update = false;

From f147f192b4cb4d641538741c773d0ef3187fdd8c Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Wed, 6 Mar 2019 10:09:27 +0100
Subject: [PATCH 2/3] Disabled object context menu when the SLA gizmo is active

---
 src/slic3r/GUI/GLCanvas3D.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 399ead284..cffc2e521 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -5298,7 +5298,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
                     if (m_hover_volume_id != -1)
                     {
                         // if right clicking on volume, propagate event through callback (shows context menu)
-                        if (m_volumes.volumes[m_hover_volume_id]->hover && !m_volumes.volumes[m_hover_volume_id]->is_wipe_tower)
+                        if (m_volumes.volumes[m_hover_volume_id]->hover
+                         && !m_volumes.volumes[m_hover_volume_id]->is_wipe_tower // no context menu for the wipe tower
+                         && m_gizmos.get_current_type() != Gizmos::SlaSupports)  // disable context menu when the gizmo is open
                         {
                             // forces the selection of the volume
                             if (!m_selection.is_multiple_full_instance())

From 79fbf0840904f00f4915919bd7642bf5e60b0ad8 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Wed, 6 Mar 2019 09:15:33 +0100
Subject: [PATCH 3/3] An attempt to fix sla gizmo imgui dialog scaling on osx
 and hidpi screens

---
 src/slic3r/GUI/GLGizmo.cpp      | 3 ++-
 src/slic3r/GUI/ImGuiWrapper.hpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp
index afffd670e..ec541b89e 100644
--- a/src/slic3r/GUI/GLGizmo.cpp
+++ b/src/slic3r/GUI/GLGizmo.cpp
@@ -2267,7 +2267,8 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l
 RENDER_AGAIN:
     m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
 
-    static const ImVec2 window_size(285.f, 260.f);
+    const float scaling = m_imgui->get_style_scaling();
+    const ImVec2 window_size(285.f * scaling, 260.f * scaling);
     ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
     ImGui::SetNextWindowSize(ImVec2(window_size));
 
diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp
index 019bb610e..35d0b5636 100644
--- a/src/slic3r/GUI/ImGuiWrapper.hpp
+++ b/src/slic3r/GUI/ImGuiWrapper.hpp
@@ -42,6 +42,8 @@ public:
     bool update_mouse_data(wxMouseEvent &evt);
     bool update_key_data(wxKeyEvent &evt);
 
+    float get_style_scaling() const { return m_style_scaling; }
+
     void new_frame();
     void render();