When system info sending fails, do not save the "sent" flag into appconfig
This commit is contained in:
parent
f51162f238
commit
efaf4e47c1
1 changed files with 9 additions and 7 deletions
|
@ -70,7 +70,7 @@ public:
|
||||||
SendSystemInfoDialog(wxWindow* parent);
|
SendSystemInfoDialog(wxWindow* parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxString send_info();
|
bool send_info(wxString& message);
|
||||||
const std::string m_system_info_json;
|
const std::string m_system_info_json;
|
||||||
wxButton* m_btn_show_data;
|
wxButton* m_btn_show_data;
|
||||||
wxButton* m_btn_send;
|
wxButton* m_btn_send;
|
||||||
|
@ -649,8 +649,11 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
|
||||||
|
|
||||||
m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&)
|
m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&)
|
||||||
{
|
{
|
||||||
if (wxString out = send_info(); !out.IsEmpty()) {
|
wxString message;
|
||||||
InfoDialog(nullptr, wxEmptyString, out).ShowModal();
|
bool success = send_info(message);
|
||||||
|
if (! message.IsEmpty())
|
||||||
|
InfoDialog(nullptr, wxEmptyString, message).ShowModal();
|
||||||
|
if (success) {
|
||||||
save_version();
|
save_version();
|
||||||
EndModal(0);
|
EndModal(0);
|
||||||
}
|
}
|
||||||
|
@ -679,7 +682,7 @@ void SendSystemInfoDialog::on_dpi_changed(const wxRect&)
|
||||||
|
|
||||||
|
|
||||||
// This actually sends the info.
|
// This actually sends the info.
|
||||||
wxString SendSystemInfoDialog::send_info()
|
bool SendSystemInfoDialog::send_info(wxString& message)
|
||||||
{
|
{
|
||||||
std::atomic<int> job_done = false; // Flag to communicate between threads.
|
std::atomic<int> job_done = false; // Flag to communicate between threads.
|
||||||
struct Result {
|
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
|
job_done = true; // In case the user closed the dialog, let the other thread know
|
||||||
sending_thread.join(); // and wait until it terminates.
|
sending_thread.join(); // and wait until it terminates.
|
||||||
|
|
||||||
if (result.value == Result::Cancelled)
|
message = result.value == Result::Cancelled ? wxString("") : result.str;
|
||||||
return "";
|
return result.value == Result::Success;
|
||||||
return result.str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue