FIX: fix crash when to press cancel button
it would crash when avatar of user is loading. cancel web request before closing dialog. Change-Id: Ib41c5d8e7b5663d15c7d7f544335b48f47c25fea Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
3aa3df00fc
commit
89c83fb8a6
|
@ -92,12 +92,12 @@ namespace GUI {
|
|||
|
||||
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
|
||||
|
||||
wxWebRequest request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
|
||||
if (!request.IsOk()) {
|
||||
web_request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
|
||||
if (!web_request.IsOk()) {
|
||||
// todo request fail
|
||||
}
|
||||
// Start the request
|
||||
request.Start();
|
||||
web_request.Start();
|
||||
}
|
||||
|
||||
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
|
||||
|
@ -209,19 +209,25 @@ namespace GUI {
|
|||
|
||||
void BindMachineDialog::on_cancel(wxCommandEvent &event)
|
||||
{
|
||||
if (m_bind_job) {
|
||||
m_bind_job->cancel();
|
||||
m_bind_job->join();
|
||||
}
|
||||
on_destroy();
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void BindMachineDialog::on_close(wxCloseEvent &event)
|
||||
void BindMachineDialog::on_destroy()
|
||||
{
|
||||
if (m_bind_job) {
|
||||
m_bind_job->cancel();
|
||||
m_bind_job->join();
|
||||
}
|
||||
|
||||
if (web_request.IsOk()) {
|
||||
web_request.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void BindMachineDialog::on_close(wxCloseEvent &event)
|
||||
{
|
||||
on_destroy();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <wx/icon.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <curl/curl.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include "wxExtensions.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Widgets/StepCtrl.hpp"
|
||||
|
@ -54,6 +55,7 @@ private:
|
|||
Button * m_button_cancel;
|
||||
wxSimplebook *m_simplebook;
|
||||
wxStaticBitmap *m_avatar;
|
||||
wxWebRequest web_request;
|
||||
|
||||
MachineObject * m_machine_info{nullptr};
|
||||
std::shared_ptr<BindJob> m_bind_job;
|
||||
|
@ -71,6 +73,7 @@ public:
|
|||
void update_machine_info(MachineObject *info) { m_machine_info = info; };
|
||||
void on_show(wxShowEvent &event);
|
||||
void on_close(wxCloseEvent& event);
|
||||
void on_destroy();
|
||||
};
|
||||
|
||||
class UnBindMachineDialog : public DPIDialog
|
||||
|
|
Loading…
Reference in New Issue