From 284355d3786d80687a37067d1083d6f70963aa5f Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 16 Sep 2019 10:22:26 +0200
Subject: [PATCH 1/5] Fix of #2878 (endless warning loop in configuration
 update)

---
 src/slic3r/GUI/GUI_ObjectSettings.cpp | 31 +++++++++++++++++++++++++++
 src/slic3r/GUI/GUI_ObjectSettings.hpp |  5 +++++
 2 files changed, 36 insertions(+)

diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp
index 0c10c5460..adb549617 100644
--- a/src/slic3r/GUI/GUI_ObjectSettings.cpp
+++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp
@@ -168,6 +168,23 @@ bool ObjectSettings::update_settings_list()
     return true;
 }
 
+bool ObjectSettings::add_missed_options(DynamicPrintConfig* config_to, const DynamicPrintConfig& config_from)
+{
+    bool is_added = false;
+    if (wxGetApp().plater()->printer_technology() == ptFFF)
+    {
+        if (config_to->has("fill_density") && !config_to->has("fill_pattern"))
+        {
+            if (config_from.option<ConfigOptionPercent>("fill_density")->value == 100) {
+                config_to->set_key_value("fill_pattern", config_from.option("fill_pattern")->clone());
+                is_added = true;
+            }
+        }
+    }
+
+    return is_added;
+}
+
 void ObjectSettings::update_config_values(DynamicPrintConfig* config)
 {
     const auto objects_model        = wxGetApp().obj_list()->GetModel();
@@ -185,6 +202,12 @@ void ObjectSettings::update_config_values(DynamicPrintConfig* config)
 
     auto load_config = [this, config, &main_config]()
     {
+        /* Additional check for overrided options.
+         * There is a case, when some options should to be added, 
+         * to avoid check loop in the next configuration update
+         */
+        bool is_added = add_missed_options(config, main_config);
+
         // load checked values from main_config to config
         config->apply_only(main_config, config->keys(), true);
         // Initialize UI components with the config values.
@@ -192,6 +215,14 @@ void ObjectSettings::update_config_values(DynamicPrintConfig* config)
             og->reload_config();
         // next config check
         update_config_values(config);
+
+        if (is_added) {
+            wxTheApp->CallAfter([this]() {
+                wxWindowUpdateLocker noUpdates(m_parent);
+                update_settings_list();
+                m_parent->Layout();
+            });
+        }
     };
 
     auto get_field = [this](const t_config_option_key & opt_key, int opt_index)
diff --git a/src/slic3r/GUI/GUI_ObjectSettings.hpp b/src/slic3r/GUI/GUI_ObjectSettings.hpp
index a5724811a..ff187eddc 100644
--- a/src/slic3r/GUI/GUI_ObjectSettings.hpp
+++ b/src/slic3r/GUI/GUI_ObjectSettings.hpp
@@ -48,6 +48,11 @@ public:
     ~ObjectSettings() {}
 
     bool        update_settings_list();
+    /* Additional check for override options: Add options, if its needed.
+     * Example: if Infill is set to 100%, and Fill Pattern is missed in config_to,
+     * we should add fill_pattern to avoid endless loop in update
+     */
+    bool        add_missed_options(DynamicPrintConfig *config_to, const DynamicPrintConfig &config_from);
     void        update_config_values(DynamicPrintConfig*config);
     void        UpdateAndShow(const bool show) override;
     void        msw_rescale();

From a12e6a7bde8c614257beb796241312b5eba657c7 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 16 Sep 2019 11:55:05 +0200
Subject: [PATCH 2/5] More clear identification if is there object selected

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

diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp
index a79426ed2..51098647f 100644
--- a/src/slic3r/GUI/GUI_ObjectList.cpp
+++ b/src/slic3r/GUI/GUI_ObjectList.cpp
@@ -1401,7 +1401,8 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
         menu->SetFirstSeparator();
 
     // Add frequently settings
-    create_freq_settings_popupmenu(menu, sel_vol==nullptr);
+    const bool is_object_settings = m_objects_model->GetItemType(GetSelection()) == itObject;
+    create_freq_settings_popupmenu(menu, is_object_settings);
 
     if (mode == comAdvanced)
         return nullptr;

From 13bde53955a9cfc7e039f13bd31c2eab3aa113ee Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 16 Sep 2019 11:56:52 +0200
Subject: [PATCH 3/5] Call update_config_values after deleting of a overridden
 option

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

diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp
index adb549617..58daec8b7 100644
--- a/src/slic3r/GUI/GUI_ObjectSettings.cpp
+++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp
@@ -106,6 +106,12 @@ bool ObjectSettings::update_settings_list()
                     update_settings_list(); 
                     m_parent->Layout(); 
                 });
+
+                /* Check overriden options list after deleting.
+                 * Some options couldn't be deleted because of another one.
+                 * Like, we couldn't delete fill pattern, if fill density is set to 100%
+                 */
+                update_config_values(config);
 			});
 			return btn;
 		};

From 519f2b62e5e327259f6de041ef458f21fd0b6d93 Mon Sep 17 00:00:00 2001
From: bubnikv <bubnikv@gmail.com>
Date: Mon, 16 Sep 2019 15:38:27 +0200
Subject: [PATCH 4/5] Fix of Perl bindings after ExtrusionEntity::clone()
 refactoring

---
 xs/xsp/ExtrusionEntityCollection.xsp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xs/xsp/ExtrusionEntityCollection.xsp b/xs/xsp/ExtrusionEntityCollection.xsp
index 731232358..a868ea6bb 100644
--- a/xs/xsp/ExtrusionEntityCollection.xsp
+++ b/xs/xsp/ExtrusionEntityCollection.xsp
@@ -9,7 +9,7 @@
     %name{_new} ExtrusionEntityCollection();
     ~ExtrusionEntityCollection();
     Clone<ExtrusionEntityCollection> clone()
-        %code{% RETVAL = THIS->clone(); %};
+        %code{% RETVAL = (ExtrusionEntityCollection*)THIS->clone(); %};
     void reverse();
     void clear();
     ExtrusionEntityCollection* chained_path(bool no_reverse, ExtrusionRole role = erMixed)

From 8e11a7b895ec5ba606df151ccded34b76eb83657 Mon Sep 17 00:00:00 2001
From: Vojtech Kral <vojtech@kral.hk>
Date: Mon, 16 Sep 2019 17:51:31 +0200
Subject: [PATCH 5/5] PresetUpdater: Fix: Sanitize downloadedsemver, fix #2927
 Use HTTPS for the slicer app version url

---
 src/slic3r/GUI/AppConfig.cpp       |  2 +-
 src/slic3r/Utils/PresetUpdater.cpp | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp
index 96213447c..5a165e8ae 100644
--- a/src/slic3r/GUI/AppConfig.cpp
+++ b/src/slic3r/GUI/AppConfig.cpp
@@ -26,7 +26,7 @@ namespace Slic3r {
 
 static const std::string VENDOR_PREFIX = "vendor:";
 static const std::string MODEL_PREFIX = "model:";
-static const std::string VERSION_CHECK_URL = "http://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
+static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
 
 void AppConfig::reset()
 {
diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp
index d55063c7b..5723afca2 100644
--- a/src/slic3r/Utils/PresetUpdater.cpp
+++ b/src/slic3r/Utils/PresetUpdater.cpp
@@ -245,6 +245,16 @@ void PresetUpdater::priv::sync_version() const
 		})
 		.on_complete([&](std::string body, unsigned /* http_status */) {
 			boost::trim(body);
+			const auto nl_pos = body.find_first_of("\n\r");
+			if (nl_pos != std::string::npos) {
+				body.resize(nl_pos);
+			}
+
+			if (! Semver::parse(body)) {
+				BOOST_LOG_TRIVIAL(warning) << boost::format("Received invalid contents from `%1%`: Not a correct semver: `%2%`") % SLIC3R_APP_NAME % body;
+				return;
+			}
+
 			BOOST_LOG_TRIVIAL(info) << boost::format("Got %1% online version: `%2%`. Sending to GUI thread...") % SLIC3R_APP_NAME % body;
 
 			wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);