From 4edae08a11c00344178c1235086348fd59c044d2 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 26 Aug 2019 16:27:51 +0200 Subject: [PATCH 1/3] UpdateDialogs: Fix: Wrap update description --- src/build-utils/CMakeLists.txt | 62 +++++++++++++++++--------------- src/slic3r/GUI/UpdateDialogs.cpp | 4 ++- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/build-utils/CMakeLists.txt b/src/build-utils/CMakeLists.txt index 3b3961b56..d47e5b97f 100644 --- a/src/build-utils/CMakeLists.txt +++ b/src/build-utils/CMakeLists.txt @@ -1,39 +1,45 @@ -add_executable(encoding-check encoding-check.cpp) +option(SLIC3R_ENC_CHECK "Verify encoding of source files" 1) -# 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 -) +if (SLIC3R_ENC_CHECK) + 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 + ) +endif() # 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) + if (SLIC3R_ENC_CHECK) + # 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} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + # 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}" ) - 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) + # 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} + 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) + endif() endfunction() diff --git a/src/slic3r/GUI/UpdateDialogs.cpp b/src/slic3r/GUI/UpdateDialogs.cpp index 2ea904007..a1a113066 100644 --- a/src/slic3r/GUI/UpdateDialogs.cpp +++ b/src/slic3r/GUI/UpdateDialogs.cpp @@ -113,7 +113,9 @@ MsgUpdateConfig::MsgUpdateConfig(const std::vector &updates) : if (! update.comment.empty()) { flex->Add(new wxStaticText(this, wxID_ANY, _(L("Comment:"))), 0, wxALIGN_RIGHT); - flex->Add(new wxStaticText(this, wxID_ANY, from_u8(update.comment))); + auto *update_comment = new wxStaticText(this, wxID_ANY, from_u8(update.comment)); + update_comment->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); + flex->Add(update_comment); } versions->Add(flex); From f9184f3564ec8805d773e331a6c25c64a24dd284 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 26 Aug 2019 16:39:08 +0200 Subject: [PATCH 2/3] PresetBundle: Add print_host to options considered security-sensitive full_config_secure() now also removes print_host option alongside printhost_apikey and printhost_cafile. --- src/slic3r/GUI/PresetBundle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index d6e99b014..af1298bfb 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -445,6 +445,7 @@ DynamicPrintConfig PresetBundle::full_config() const DynamicPrintConfig PresetBundle::full_config_secure() const { DynamicPrintConfig config = this->full_config(); + config.erase("print_host"); config.erase("printhost_apikey"); config.erase("printhost_cafile"); return config; From 8b7f0c53594241bb2af062ada3d62575c51b9c80 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 26 Aug 2019 17:17:23 +0200 Subject: [PATCH 3/3] Refactor a few more `catch(...)` instances --- src/avrdude/avrdude-slic3r.cpp | 12 ------------ src/slic3r/GUI/GUI_App.cpp | 5 +---- src/slic3r/Utils/Serial.cpp | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/avrdude/avrdude-slic3r.cpp b/src/avrdude/avrdude-slic3r.cpp index 7eff436e2..b561cd843 100644 --- a/src/avrdude/avrdude-slic3r.cpp +++ b/src/avrdude/avrdude-slic3r.cpp @@ -204,18 +204,6 @@ AvrDude::Ptr AvrDude::run() message_fn("\n", 1); } - if (self->p->complete_fn) { - self->p->complete_fn(); - } - } catch (...) { - self->p->exit_code = EXIT_EXCEPTION; - - static const char *msg = "An unkown exception was thrown in the background thread.\n"; - - if (self->p->message_fn) { - self->p->message_fn(msg, sizeof(msg)); - } - if (self->p->complete_fn) { self->p->complete_fn(); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 9fe0bab96..2b6344783 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -139,9 +139,6 @@ static void generic_exception_handle() wxLogError("Internal error: %s", ex.what()); BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what(); throw; - } catch (...) { - wxLogError("Unknown internal error"); - BOOST_LOG_TRIVIAL(error) << "Uncaught exception: Unknown error"; } } @@ -169,7 +166,7 @@ bool GUI_App::OnInit() { try { return on_init_inner(); - } catch (...) { + } catch (const std::exception&) { generic_exception_handle(); return false; } diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp index 594464692..737e76c0b 100644 --- a/src/slic3r/Utils/Serial.cpp +++ b/src/slic3r/Utils/Serial.cpp @@ -98,7 +98,7 @@ optional sysfs_tty_prop_hex(const std::string &tty_dev, const std if (!prop) { return boost::none; } try { return std::stoul(*prop, 0, 16); } - catch (...) { return boost::none; } + catch (const std::exception&) { return boost::none; } } #endif