From efaf4e47c1c94f78bc75568a778731c29b24bcfd Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 30 Nov 2021 16:19:36 +0100 Subject: [PATCH] When system info sending fails, do not save the "sent" flag into appconfig --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index 9db272d35..0bfb343b8 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -70,7 +70,7 @@ public: SendSystemInfoDialog(wxWindow* parent); private: - wxString send_info(); + bool send_info(wxString& message); const std::string m_system_info_json; wxButton* m_btn_show_data; wxButton* m_btn_send; @@ -649,8 +649,11 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent) m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&) { - if (wxString out = send_info(); !out.IsEmpty()) { - InfoDialog(nullptr, wxEmptyString, out).ShowModal(); + wxString message; + bool success = send_info(message); + if (! message.IsEmpty()) + InfoDialog(nullptr, wxEmptyString, message).ShowModal(); + if (success) { save_version(); EndModal(0); } @@ -679,7 +682,7 @@ void SendSystemInfoDialog::on_dpi_changed(const wxRect&) // This actually sends the info. -wxString SendSystemInfoDialog::send_info() +bool SendSystemInfoDialog::send_info(wxString& message) { std::atomic job_done = false; // Flag to communicate between threads. struct Result { @@ -723,9 +726,8 @@ wxString SendSystemInfoDialog::send_info() job_done = true; // In case the user closed the dialog, let the other thread know sending_thread.join(); // and wait until it terminates. - if (result.value == Result::Cancelled) - return ""; - return result.str; + message = result.value == Result::Cancelled ? wxString("") : result.str; + return result.value == Result::Success; }