From 88bf7c852cc25fb4573950e21370143024103f31 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Sat, 21 Jul 2018 09:32:45 +0200 Subject: [PATCH] Fixed upgrade of vendor profile from the application resources after an upgrade of the application. --- lib/Slic3r/GUI.pm | 3 ++- xs/src/slic3r/Utils/PresetUpdater.cpp | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 80130fefe..cbfe0e5fe 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -169,7 +169,8 @@ sub OnInit { $self->update_ui_from_settings; }); - # The following event is emited by PresetUpdater (C++) + # The following event is emited by PresetUpdater (C++) to inform about + # the newer Slic3r application version avaiable online. EVT_COMMAND($self, -1, $VERSION_ONLINE_EVENT, sub { my ($self, $event) = @_; my $version = $event->GetString; diff --git a/xs/src/slic3r/Utils/PresetUpdater.cpp b/xs/src/slic3r/Utils/PresetUpdater.cpp index 1ce814b89..7ed963a16 100644 --- a/xs/src/slic3r/Utils/PresetUpdater.cpp +++ b/xs/src/slic3r/Utils/PresetUpdater.cpp @@ -326,6 +326,8 @@ Updates PresetUpdater::priv::get_config_updates() const continue; } + // Getting a recommended version from the latest index, wich may have been downloaded + // from the internet, or installed / updated from the installation resources. const auto recommended = idx.recommended(); if (recommended == idx.end()) { BOOST_LOG_TRIVIAL(error) << boost::format("No recommended version for vendor: %1%, invalid index?") % idx.vendor(); @@ -353,25 +355,34 @@ Updates PresetUpdater::priv::get_config_updates() const } auto path_src = cache_path / (idx.vendor() + ".ini"); + auto path_in_rsrc = rsrc_path / (idx.vendor() + ".ini"); if (! fs::exists(path_src)) { - auto path_in_rsrc = rsrc_path / (idx.vendor() + ".ini"); if (! fs::exists(path_in_rsrc)) { BOOST_LOG_TRIVIAL(warning) << boost::format("Index for vendor %1% indicates update, but bundle found in neither cache nor resources") - % idx.vendor();; + % idx.vendor(); continue; } else { path_src = std::move(path_in_rsrc); + path_in_rsrc.clear(); } } - const auto new_vp = VendorProfile::from_ini(path_src, false); + auto new_vp = VendorProfile::from_ini(path_src, false); + bool found = false; if (new_vp.config_version == recommended->config_version) { updates.updates.emplace_back(std::move(path_src), std::move(bundle_path), *recommended); - } else { + found = true; + } else if (! path_in_rsrc.empty() && fs::exists(path_in_rsrc)) { + new_vp = VendorProfile::from_ini(path_in_rsrc, false); + if (new_vp.config_version == recommended->config_version) { + updates.updates.emplace_back(std::move(path_in_rsrc), std::move(bundle_path), *recommended); + found = true; + } + } + if (! found) BOOST_LOG_TRIVIAL(warning) << boost::format("Index for vendor %1% indicates update (%2%) but the new bundle was found neither in cache nor resources") % idx.vendor() % recommended->config_version.to_string(); - } } }