FIX: gui: fix the crash issue when close guide frame at the beginning

jira: STUDIO-9941
Change-Id: I47e189e838ae606d294d0c0b4ccffc6f833a27c3
(cherry picked from commit 093a7c25cb7507d0d6af228c2efa3410e1184c27)
This commit is contained in:
lane.wei 2025-01-17 20:23:29 +08:00 committed by Noisyfox
parent 5e79e9196f
commit cf0c5624a1
2 changed files with 29 additions and 14 deletions

View file

@ -187,6 +187,12 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
GuideFrame::~GuideFrame()
{
m_destroy = true;
if (m_load_task && m_load_task->joinable()) {
m_load_task->join();
delete m_load_task;
m_load_task = nullptr;
}
if (m_browser) {
delete m_browser;
m_browser = nullptr;
@ -296,8 +302,9 @@ void GuideFrame::OnNavigationComplete(wxWebViewEvent &evt)
{
//wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
if (!bFirstComplete) {
boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfileData, this));
LoadProfileThread.detach();
m_load_task = new boost::thread(boost::bind(&GuideFrame::LoadProfileData, this));
// boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfileData, this));
//LoadProfileThread.detach();
bFirstComplete = true;
}
@ -1028,6 +1035,8 @@ int GuideFrame::LoadProfileData()
LoadProfileFamily(w2s(strVendor), iter->path().string());
loaded_vendors.insert(w2s(strVendor));
}
if (m_destroy)
return 0;
}
boost::filesystem::directory_iterator others_endIter;
@ -1043,6 +1052,8 @@ int GuideFrame::LoadProfileData()
LoadProfileFamily(w2s(strVendor), iter->path().string());
loaded_vendors.insert(w2s(strVendor));
}
if (m_destroy)
return 0;
}
//sync to web
@ -1053,9 +1064,11 @@ int GuideFrame::LoadProfileData()
m_Res["command"] = "userguide_profile_load_finish";
m_Res["sequence_id"] = "10001";
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
if (!m_destroy)
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
//sync to appconfig
if (!m_destroy)
wxGetApp().CallAfter([this] { SaveProfileData(); });
} catch (std::exception& e) {

View file

@ -110,6 +110,8 @@ private:
//First Load
bool bFirstComplete{false};
bool m_destroy{false};
boost::thread* m_load_task{ nullptr };
// User Config
bool PrivacyUse;