mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 18:49:05 +08:00
Merge branch 'vk-bugfixes'
This commit is contained in:
commit
93983b7864
@ -1,5 +1,6 @@
|
||||
project(PrusaSlicer-native)
|
||||
|
||||
add_subdirectory(build-utils)
|
||||
add_subdirectory(admesh)
|
||||
add_subdirectory(avrdude)
|
||||
# boost/nowide
|
||||
|
@ -86,7 +86,7 @@ add_executable(avrdude-conf-gen conf-generate.cpp)
|
||||
add_custom_command(
|
||||
DEPENDS avrdude-conf-gen ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/avrdude-slic3r.conf.h
|
||||
COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf > avrdude-slic3r.conf.h
|
||||
COMMAND $<TARGET_FILE:avrdude-conf-gen> avrdude-slic3r.conf avrdude_slic3r_conf avrdude-slic3r.conf.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
@ -100,6 +100,9 @@ add_dependencies(avrdude gen_conf_h)
|
||||
add_executable(avrdude-slic3r main-standalone.cpp)
|
||||
target_link_libraries(avrdude-slic3r avrdude)
|
||||
|
||||
encoding_check(avrdude)
|
||||
encoding_check(avrdude-slic3r)
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1)
|
||||
if(MSVC)
|
||||
|
@ -6,36 +6,42 @@
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " <file> <symbol name>" << std::endl;
|
||||
if (argc != 4) {
|
||||
std::cerr << "Usage: " << argv[0] << " <file> <symbol name> <output file>" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* filename = argv[1];
|
||||
const char* filename_in = argv[1];
|
||||
const char* symbol = argv[2];
|
||||
const char* filename_out = argv[3];
|
||||
|
||||
size_t size = 0;
|
||||
std::fstream file(filename);
|
||||
std::fstream file(filename_in, std::ios::in | std::ios::binary);
|
||||
if (!file.good()) {
|
||||
std::cerr << "Cannot read file: " << filename << std::endl;
|
||||
std::cerr << "Cannot read file: " << filename_in << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "/* WARN: This file is auto-generated from `" << filename << "` */" << std::endl;
|
||||
std::cout << "const unsigned char " << symbol << "[] = {";
|
||||
std::fstream output(filename_out, std::ios::out | std::ios::trunc | std::ios::binary);
|
||||
if (!output.good()) {
|
||||
std::cerr << "Cannot open output file: " << filename_out << std::endl;
|
||||
}
|
||||
|
||||
output << "/* WARN: This file is auto-generated from `" << filename_in << "` */" << std::endl;
|
||||
output << "const unsigned char " << symbol << "[] = {";
|
||||
|
||||
char c;
|
||||
std::cout << std::hex;
|
||||
std::cout.fill('0');
|
||||
output << std::hex;
|
||||
output.fill('0');
|
||||
for (file.get(c); !file.eof(); size++, file.get(c)) {
|
||||
if (size % 12 == 0) { std::cout << "\n "; }
|
||||
std::cout << "0x" << std::setw(2) << (unsigned)c << ", ";
|
||||
if (size % 12 == 0) { output << "\n "; }
|
||||
output << "0x" << std::setw(2) << (unsigned)c << ", ";
|
||||
}
|
||||
|
||||
std::cout << "\n 0, 0\n};\n";
|
||||
output << "\n 0, 0\n};\n";
|
||||
|
||||
std::cout << std::dec;
|
||||
std::cout << "const size_t " << symbol << "_size = " << size << ";" << std::endl;
|
||||
std::cout << "const size_t " << symbol << "_size_yy = " << size + 2 << ";" << std::endl;
|
||||
output << std::dec;
|
||||
output << "const size_t " << symbol << "_size = " << size << ";" << std::endl;
|
||||
output << "const size_t " << symbol << "_size_yy = " << size + 2 << ";" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
39
src/build-utils/CMakeLists.txt
Normal file
39
src/build-utils/CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
add_executable(encoding-check encoding-check.cpp)
|
||||
|
||||
# A global no-op target which depends on all encodings checks,
|
||||
# and on which in turn all checked targets depend.
|
||||
# This is done to make encoding checks the first thing to be
|
||||
# performed before actually compiling any sources of the checked targets
|
||||
# to make the check fail as early as possible.
|
||||
add_custom_target(global-encoding-check
|
||||
ALL
|
||||
DEPENDS encoding-check
|
||||
)
|
||||
|
||||
# Function that adds source file encoding check to a target
|
||||
# using the above encoding-check binary
|
||||
|
||||
function(encoding_check TARGET)
|
||||
# Obtain target source files
|
||||
get_target_property(T_SOURCES ${TARGET} SOURCES)
|
||||
|
||||
# Define top-level encoding check target for this ${TARGET}
|
||||
add_custom_target(encoding-check-${TARGET}
|
||||
DEPENDS encoding-check ${T_SOURCES}
|
||||
COMMENT "Checking source files encodings for target ${TARGET}"
|
||||
)
|
||||
|
||||
# Add checking of each source file as a subcommand of encoding-check-${TARGET}
|
||||
foreach(file ${T_SOURCES})
|
||||
add_custom_command(TARGET encoding-check-${TARGET}
|
||||
COMMAND $<TARGET_FILE:encoding-check> ${TARGET} ${file}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# This adds dependency on encoding-check-${TARGET} to ${TARET}
|
||||
# via the global-encoding-check
|
||||
add_dependencies(global-encoding-check encoding-check-${TARGET})
|
||||
add_dependencies(${TARGET} global-encoding-check)
|
||||
endfunction()
|
119
src/build-utils/encoding-check.cpp
Normal file
119
src/build-utils/encoding-check.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
/*
|
||||
* The utf8_check() function scans the '\0'-terminated string starting
|
||||
* at s. It returns a pointer to the first byte of the first malformed
|
||||
* or overlong UTF-8 sequence found, or NULL if the string contains
|
||||
* only correct UTF-8. It also spots UTF-8 sequences that could cause
|
||||
* trouble if converted to UTF-16, namely surrogate characters
|
||||
* (U+D800..U+DFFF) and non-Unicode positions (U+FFFE..U+FFFF). This
|
||||
* routine is very likely to find a malformed sequence if the input
|
||||
* uses any other encoding than UTF-8. It therefore can be used as a
|
||||
* very effective heuristic for distinguishing between UTF-8 and other
|
||||
* encodings.
|
||||
*
|
||||
* I wrote this code mainly as a specification of functionality; there
|
||||
* are no doubt performance optimizations possible for certain CPUs.
|
||||
*
|
||||
* Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> -- 2005-03-30
|
||||
* License: http://www.cl.cam.ac.uk/~mgk25/short-license.html
|
||||
*/
|
||||
|
||||
unsigned char *utf8_check(unsigned char *s)
|
||||
{
|
||||
while (*s) {
|
||||
if (*s < 0x80) {
|
||||
// 0xxxxxxx
|
||||
s++;
|
||||
} else if ((s[0] & 0xe0) == 0xc0) {
|
||||
// 110xxxxx 10xxxxxx
|
||||
if ((s[1] & 0xc0) != 0x80 ||
|
||||
(s[0] & 0xfe) == 0xc0) { // overlong?
|
||||
return s;
|
||||
} else {
|
||||
s += 2;
|
||||
}
|
||||
} else if ((s[0] & 0xf0) == 0xe0) {
|
||||
// 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if ((s[1] & 0xc0) != 0x80 ||
|
||||
(s[2] & 0xc0) != 0x80 ||
|
||||
(s[0] == 0xe0 && (s[1] & 0xe0) == 0x80) || // overlong?
|
||||
(s[0] == 0xed && (s[1] & 0xe0) == 0xa0) || // surrogate?
|
||||
(s[0] == 0xef && s[1] == 0xbf &&
|
||||
(s[2] & 0xfe) == 0xbe)) { // U+FFFE or U+FFFF?
|
||||
return s;
|
||||
} else {
|
||||
s += 3;
|
||||
}
|
||||
} else if ((s[0] & 0xf8) == 0xf0) {
|
||||
// 11110xxX 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if ((s[1] & 0xc0) != 0x80 ||
|
||||
(s[2] & 0xc0) != 0x80 ||
|
||||
(s[3] & 0xc0) != 0x80 ||
|
||||
(s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) || // overlong?
|
||||
(s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4) { // > U+10FFFF?
|
||||
return s;
|
||||
} else {
|
||||
s += 4;
|
||||
}
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " <program/library> <file>" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* target = argv[1];
|
||||
const char* filename = argv[2];
|
||||
|
||||
const auto error_exit = [=](const char* error) {
|
||||
std::cerr << "\n\tError: " << error << ": " << filename << "\n"
|
||||
<< "\tTarget: " << target << "\n"
|
||||
<< std::endl;
|
||||
std::exit(-2);
|
||||
};
|
||||
|
||||
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||
const auto size = file.tellg();
|
||||
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
file.seekg(0, std::ios::beg);
|
||||
std::vector<char> buffer(size);
|
||||
|
||||
if (file.read(buffer.data(), size)) {
|
||||
buffer.push_back('\0');
|
||||
|
||||
// Check UTF-8 validity
|
||||
if (utf8_check(reinterpret_cast<unsigned char*>(buffer.data())) != nullptr) {
|
||||
error_exit("Source file does not contain (valid) UTF-8");
|
||||
}
|
||||
|
||||
// Check against a BOM mark
|
||||
if (buffer.size() >= 3
|
||||
&& buffer[0] == '\xef'
|
||||
&& buffer[1] == '\xbb'
|
||||
&& buffer[2] == '\xbf') {
|
||||
error_exit("Source file is valid UTF-8 but contains a BOM mark");
|
||||
}
|
||||
} else {
|
||||
error_exit("Could not read source file");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -139,6 +139,7 @@ add_library(libslic3r STATIC
|
||||
PrintConfig.hpp
|
||||
PrintObject.cpp
|
||||
PrintRegion.cpp
|
||||
Semver.cpp
|
||||
SLAPrint.cpp
|
||||
SLAPrint.hpp
|
||||
SLA/SLAAutoSupports.hpp
|
||||
@ -186,6 +187,8 @@ add_library(libslic3r STATIC
|
||||
SLA/SLARasterWriter.cpp
|
||||
)
|
||||
|
||||
encoding_check(libslic3r)
|
||||
|
||||
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
||||
add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE)
|
||||
endif ()
|
||||
|
7
src/libslic3r/Semver.cpp
Normal file
7
src/libslic3r/Semver.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "libslic3r.h"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
Semver SEMVER { SLIC3R_VERSION };
|
||||
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "Technologies.hpp"
|
||||
#include "Semver.hpp"
|
||||
|
||||
typedef int32_t coord_t;
|
||||
typedef double coordf_t;
|
||||
@ -92,6 +93,8 @@ inline std::string debug_out_path(const char *name, ...)
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
extern Semver SEMVER;
|
||||
|
||||
template<typename T, typename Q>
|
||||
inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
|
||||
|
||||
|
@ -5,3 +5,5 @@ add_library(semver STATIC
|
||||
semver.c
|
||||
semver.h
|
||||
)
|
||||
|
||||
encoding_check(semver)
|
||||
|
@ -163,6 +163,8 @@ endif ()
|
||||
|
||||
add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES})
|
||||
|
||||
encoding_check(libslic3r_gui)
|
||||
|
||||
target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui ${GLEW_LIBRARIES})
|
||||
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
||||
add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
|
||||
|
@ -366,7 +366,7 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot:
|
||||
// Snapshot header.
|
||||
snapshot.time_captured = Slic3r::Utils::get_current_time_utc();
|
||||
snapshot.id = Slic3r::Utils::format_time_ISO8601Z(snapshot.time_captured);
|
||||
snapshot.slic3r_version_captured = *Semver::parse(SLIC3R_VERSION); // XXX: have Semver Slic3r version
|
||||
snapshot.slic3r_version_captured = Slic3r::SEMVER;
|
||||
snapshot.comment = comment;
|
||||
snapshot.reason = reason;
|
||||
// Active presets at the time of the snapshot.
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "libslic3r/Semver.hpp"
|
||||
#include "Version.hpp"
|
||||
#include "../Utils/Semver.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -15,7 +15,6 @@ namespace Slic3r {
|
||||
namespace GUI {
|
||||
namespace Config {
|
||||
|
||||
static const Semver s_current_slic3r_semver(SLIC3R_VERSION);
|
||||
|
||||
// Optimized lexicographic compare of two pre-release versions, ignoring the numeric suffix.
|
||||
static int compare_prerelease(const char *p1, const char *p2)
|
||||
@ -64,7 +63,7 @@ bool Version::is_slic3r_supported(const Semver &slic3r_version) const
|
||||
|
||||
bool Version::is_current_slic3r_supported() const
|
||||
{
|
||||
return this->is_slic3r_supported(s_current_slic3r_semver);
|
||||
return this->is_slic3r_supported(Slic3r::SEMVER);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "libslic3r/FileParserError.hpp"
|
||||
#include "../Utils/Semver.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -76,9 +76,9 @@ void CopyrightsDialog::fill_entries()
|
||||
{
|
||||
m_entries = {
|
||||
{ "wxWidgets" , "2019 wxWidgets" , "https://www.wxwidgets.org/" },
|
||||
{ "OpenGL" , "1997-2019 The Khronos™ Group Inc" , "https://www.opengl.org/" },
|
||||
{ "OpenGL" , "1997-2019 The Khronos™ Group Inc" , "https://www.opengl.org/" },
|
||||
{ "GNU gettext" , "1998, 2019 Free Software Foundation, Inc." , "https://www.gnu.org/software/gettext/" },
|
||||
{ "PoEdit" , "2019 Václav Slavík" , "https://poedit.net/" },
|
||||
{ "PoEdit" , "2019 Václav Slavík" , "https://poedit.net/" },
|
||||
{ "ImGUI" , "2014-2019 Omar Cornut" , "https://github.com/ocornut/imgui" },
|
||||
{ "Eigen" , "" , "http://eigen.tuxfamily.org" },
|
||||
{ "ADMesh" , "1995, 1996 Anthony D. Martin; "
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "slic3r/Utils/Semver.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef slic3r_MainFrame_hpp_
|
||||
#ifndef slic3r_MainFrame_hpp_
|
||||
#define slic3r_MainFrame_hpp_
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include <wx/font.h>
|
||||
#include <wx/bitmap.h>
|
||||
|
||||
#include "slic3r/Utils/Semver.hpp"
|
||||
|
||||
class wxBoxSizer;
|
||||
class wxCheckBox;
|
||||
class wxStaticBitmap;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "ConfigExceptions.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "slic3r/Utils/Semver.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
|
||||
class wxBitmap;
|
||||
class wxBitmapComboBox;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "slic3r/Utils/Semver.hpp"
|
||||
#include "libslic3r/Semver.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
|
||||
class wxBoxSizer;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <thread>
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
@ -165,7 +166,7 @@ size_t Http::priv::form_file_read_cb(char *buffer, size_t size, size_t nitems, v
|
||||
|
||||
try {
|
||||
stream->read(buffer, size * nitems);
|
||||
} catch (...) {
|
||||
} catch (const std::exception &) {
|
||||
return CURL_READFUNC_ABORT;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
@ -69,7 +70,7 @@ bool OctoPrint::test(wxString &msg) const
|
||||
msg = wxString::Format(_(L("Mismatched type of print host: %s")), text ? *text : "OctoPrint");
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
catch (const std::exception &) {
|
||||
res = false;
|
||||
msg = "Could not parse server response";
|
||||
}
|
||||
|
@ -101,6 +101,17 @@ struct Incompat
|
||||
, vendor(std::move(vendor))
|
||||
{}
|
||||
|
||||
void remove() {
|
||||
// Remove the bundle file
|
||||
fs::remove(bundle);
|
||||
|
||||
// Look for an installed index and remove it too if any
|
||||
const fs::path installed_idx = bundle.replace_extension("idx");
|
||||
if (fs::exists(installed_idx)) {
|
||||
fs::remove(installed_idx);
|
||||
}
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os , const Incompat &self) {
|
||||
os << "Incompat(" << self.bundle.string() << ')';
|
||||
return os;
|
||||
@ -113,25 +124,12 @@ struct Updates
|
||||
std::vector<Update> updates;
|
||||
};
|
||||
|
||||
static Semver get_slic3r_version()
|
||||
{
|
||||
auto res = Semver::parse(SLIC3R_VERSION);
|
||||
|
||||
if (! res) {
|
||||
const char *error = "Could not parse Slic3r version string: " SLIC3R_VERSION;
|
||||
BOOST_LOG_TRIVIAL(error) << error;
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
||||
return *res;
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
|
||||
|
||||
|
||||
struct PresetUpdater::priv
|
||||
{
|
||||
const Semver ver_slic3r;
|
||||
std::vector<Index> index_db;
|
||||
|
||||
bool enabled_version_check;
|
||||
@ -159,8 +157,7 @@ struct PresetUpdater::priv
|
||||
};
|
||||
|
||||
PresetUpdater::priv::priv()
|
||||
: ver_slic3r(get_slic3r_version())
|
||||
, cache_path(fs::path(Slic3r::data_dir()) / "cache")
|
||||
: cache_path(fs::path(Slic3r::data_dir()) / "cache")
|
||||
, rsrc_path(fs::path(resources_dir()) / "profiles")
|
||||
, vendor_path(fs::path(Slic3r::data_dir()) / "vendor")
|
||||
, cancel(false)
|
||||
@ -383,25 +380,6 @@ Updates PresetUpdater::priv::get_config_updates() const
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load 'installed' idx, if any.
|
||||
// 'Installed' indices are kept alongside the bundle in the `vendor` subdir
|
||||
// for bookkeeping to remember a cancelled update and not offer it again.
|
||||
if (fs::exists(bundle_path_idx)) {
|
||||
Index existing_idx;
|
||||
try {
|
||||
existing_idx.load(bundle_path_idx);
|
||||
|
||||
const auto existing_recommended = existing_idx.recommended();
|
||||
if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) {
|
||||
// The user has already seen (and presumably rejected) this update
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Downloaded index for `%1%` is the same as installed one, not offering an update.") % idx.vendor();
|
||||
continue;
|
||||
}
|
||||
} catch (const std::exception & /* err */) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Could nto load installed index %1%") % bundle_path_idx;
|
||||
}
|
||||
}
|
||||
|
||||
const auto ver_current = idx.find(vp.config_version);
|
||||
const bool ver_current_found = ver_current != idx.end();
|
||||
|
||||
@ -424,6 +402,25 @@ Updates PresetUpdater::priv::get_config_updates() const
|
||||
} else if (recommended->config_version > vp.config_version) {
|
||||
// Config bundle update situation
|
||||
|
||||
// Load 'installed' idx, if any.
|
||||
// 'Installed' indices are kept alongside the bundle in the `vendor` subdir
|
||||
// for bookkeeping to remember a cancelled update and not offer it again.
|
||||
if (fs::exists(bundle_path_idx)) {
|
||||
Index existing_idx;
|
||||
try {
|
||||
existing_idx.load(bundle_path_idx);
|
||||
|
||||
const auto existing_recommended = existing_idx.recommended();
|
||||
if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) {
|
||||
// The user has already seen (and presumably rejected) this update
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Downloaded index for `%1%` is the same as installed one, not offering an update.") % idx.vendor();
|
||||
continue;
|
||||
}
|
||||
} catch (const std::exception &err) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Could not load installed index at `%1%`: %2%") % bundle_path_idx % err.what();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the update is already present in a snapshot
|
||||
const auto recommended_snap = SnapshotDB::singleton().snapshot_with_vendor_preset(vp.name, recommended->config_version);
|
||||
if (recommended_snap != SnapshotDB::singleton().end()) {
|
||||
@ -485,12 +482,11 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% incompatible bundles") % updates.incompats.size();
|
||||
|
||||
for (const auto &incompat : updates.incompats) {
|
||||
for (auto &incompat : updates.incompats) {
|
||||
BOOST_LOG_TRIVIAL(info) << '\t' << incompat;
|
||||
fs::remove(incompat.bundle);
|
||||
incompat.remove();
|
||||
}
|
||||
}
|
||||
else if (updates.updates.size() > 0) {
|
||||
} else if (updates.updates.size() > 0) {
|
||||
if (snapshot) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Taking a snapshot...";
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_UPGRADE);
|
||||
@ -584,8 +580,8 @@ void PresetUpdater::slic3r_update_notify()
|
||||
|
||||
if (ver_online) {
|
||||
// Only display the notification if the version available online is newer AND if we haven't seen it before
|
||||
if (*ver_online > p->ver_slic3r && (! ver_online_seen || *ver_online_seen < *ver_online)) {
|
||||
GUI::MsgUpdateSlic3r notification(p->ver_slic3r, *ver_online);
|
||||
if (*ver_online > Slic3r::SEMVER && (! ver_online_seen || *ver_online_seen < *ver_online)) {
|
||||
GUI::MsgUpdateSlic3r notification(Slic3r::SEMVER, *ver_online);
|
||||
notification.ShowModal();
|
||||
if (notification.disable_version_check()) {
|
||||
app_config->set("version_check", "0");
|
||||
|
@ -170,8 +170,6 @@ void PrintHostJobQueue::priv::bg_thread_main()
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
emit_error(e.what());
|
||||
} catch (...) {
|
||||
emit_error("Unknown exception");
|
||||
}
|
||||
|
||||
// Cleanup leftover files, if any
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <fstream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@ -71,13 +72,10 @@ void parse_hardware_id(const std::string &hardware_id, SerialPortInfo &spi)
|
||||
std::regex pattern("USB\\\\.*VID_([[:xdigit:]]+)&PID_([[:xdigit:]]+).*");
|
||||
std::smatch matches;
|
||||
if (std::regex_match(hardware_id, matches, pattern)) {
|
||||
try {
|
||||
vid = std::stoul(matches[1].str(), 0, 16);
|
||||
pid = std::stoul(matches[2].str(), 0, 16);
|
||||
spi.id_vendor = vid;
|
||||
spi.id_product = pid;
|
||||
}
|
||||
catch (...) {}
|
||||
vid = std::stoul(matches[1].str(), 0, 16);
|
||||
pid = std::stoul(matches[2].str(), 0, 16);
|
||||
spi.id_vendor = vid;
|
||||
spi.id_product = pid;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user