FIX: gui: fix the crash issue when close guide frame at the beginning
jira: STUDIO-9941 Change-Id: I47e189e838ae606d294d0c0b4ccffc6f833a27c3
This commit is contained in:
parent
da0fe0b4e2
commit
093a7c25cb
|
@ -44,7 +44,7 @@ static wxString update_custom_filaments()
|
||||||
json m_CustomFilaments = json::array();
|
json m_CustomFilaments = json::array();
|
||||||
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
||||||
std::map<std::string, std::vector<Preset const *>> temp_filament_id_to_presets = preset_bundle->filaments.get_filament_presets();
|
std::map<std::string, std::vector<Preset const *>> temp_filament_id_to_presets = preset_bundle->filaments.get_filament_presets();
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> need_sort;
|
std::vector<std::pair<std::string, std::string>> need_sort;
|
||||||
bool need_delete_some_filament = false;
|
bool need_delete_some_filament = false;
|
||||||
for (std::pair<std::string, std::vector<Preset const *>> filament_id_to_presets : temp_filament_id_to_presets) {
|
for (std::pair<std::string, std::vector<Preset const *>> filament_id_to_presets : temp_filament_id_to_presets) {
|
||||||
|
@ -68,7 +68,7 @@ static wxString update_custom_filaments()
|
||||||
auto filament_vendor = dynamic_cast<ConfigOptionStrings *>(const_cast<Preset *>(preset)->config.option("filament_vendor", false));
|
auto filament_vendor = dynamic_cast<ConfigOptionStrings *>(const_cast<Preset *>(preset)->config.option("filament_vendor", false));
|
||||||
if (filament_vendor && filament_vendor->values.size() && filament_vendor->values[0] == "Generic") not_need_show = true;
|
if (filament_vendor && filament_vendor->values.size() && filament_vendor->values[0] == "Generic") not_need_show = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filament_name.empty()) {
|
if (filament_name.empty()) {
|
||||||
std::string preset_name = preset->name;
|
std::string preset_name = preset->name;
|
||||||
size_t index_at = preset_name.find(" @");
|
size_t index_at = preset_name.find(" @");
|
||||||
|
@ -127,7 +127,7 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
|
||||||
}
|
}
|
||||||
m_browser->Hide();
|
m_browser->Hide();
|
||||||
m_browser->SetSize(0, 0);
|
m_browser->SetSize(0, 0);
|
||||||
|
|
||||||
SetSizer(topsizer);
|
SetSizer(topsizer);
|
||||||
|
|
||||||
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
||||||
|
@ -182,6 +182,12 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
|
||||||
|
|
||||||
GuideFrame::~GuideFrame()
|
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) {
|
if (m_browser) {
|
||||||
delete m_browser;
|
delete m_browser;
|
||||||
m_browser = nullptr;
|
m_browser = nullptr;
|
||||||
|
@ -291,15 +297,16 @@ void GuideFrame::OnNavigationComplete(wxWebViewEvent &evt)
|
||||||
{
|
{
|
||||||
//wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
|
//wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
|
||||||
if (!bFirstComplete) {
|
if (!bFirstComplete) {
|
||||||
boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfileData, this));
|
m_load_task = new boost::thread(boost::bind(&GuideFrame::LoadProfileData, this));
|
||||||
LoadProfileThread.detach();
|
// boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfileData, this));
|
||||||
|
//LoadProfileThread.detach();
|
||||||
|
|
||||||
bFirstComplete = true;
|
bFirstComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_browser->Show();
|
m_browser->Show();
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
wxString NewUrl = evt.GetURL();
|
wxString NewUrl = evt.GetURL();
|
||||||
|
|
||||||
UpdateState();
|
UpdateState();
|
||||||
|
@ -490,7 +497,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
InstallNetplugin = false;
|
InstallNetplugin = false;
|
||||||
}
|
}
|
||||||
else if (strCmd == "common_openurl")
|
else if (strCmd == "common_openurl")
|
||||||
{
|
{
|
||||||
std::string strUrl = j["url"];
|
std::string strUrl = j["url"];
|
||||||
|
@ -1014,9 +1021,9 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
||||||
if (jLocal.contains("inherits")) {
|
if (jLocal.contains("inherits")) {
|
||||||
std::string FName = jLocal["inherits"];
|
std::string FName = jLocal["inherits"];
|
||||||
|
|
||||||
if (!pFilaList.contains(FName)) {
|
if (!pFilaList.contains(FName)) {
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "pFilaList - Not Contains inherits filaments: " << FName;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "pFilaList - Not Contains inherits filaments: " << FName;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FPath = pFilaList[FName]["sub_path"];
|
std::string FPath = pFilaList[FName]["sub_path"];
|
||||||
|
@ -1103,6 +1110,8 @@ int GuideFrame::LoadProfileData()
|
||||||
|
|
||||||
if (w2s(strVendor) == PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0) LoadProfileFamily(w2s(strVendor), iter->path().string());
|
if (w2s(strVendor) == PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0) LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||||
}
|
}
|
||||||
|
if (m_destroy)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// string others_targetPath = rsrc_vendor_dir.string();
|
// string others_targetPath = rsrc_vendor_dir.string();
|
||||||
|
@ -1121,6 +1130,8 @@ int GuideFrame::LoadProfileData()
|
||||||
|
|
||||||
if (w2s(strVendor) != PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0) LoadProfileFamily(w2s(strVendor), iter->path().string());
|
if (w2s(strVendor) != PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0) LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||||
}
|
}
|
||||||
|
if (m_destroy)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sync to web
|
//sync to web
|
||||||
|
@ -1131,12 +1142,14 @@ int GuideFrame::LoadProfileData()
|
||||||
m_Res["command"] = "userguide_profile_load_finish";
|
m_Res["command"] = "userguide_profile_load_finish";
|
||||||
m_Res["sequence_id"] = "10001";
|
m_Res["sequence_id"] = "10001";
|
||||||
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
|
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
|
||||||
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
if (!m_destroy)
|
||||||
|
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
||||||
|
|
||||||
//sync to appconfig
|
//sync to appconfig
|
||||||
wxGetApp().CallAfter([this] { SaveProfileData(); });
|
if (!m_destroy)
|
||||||
|
wxGetApp().CallAfter([this] { SaveProfileData(); });
|
||||||
|
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception& e) {
|
||||||
// wxLogMessage("GUIDE: load_profile_error %s ", e.what());
|
// wxLogMessage("GUIDE: load_profile_error %s ", e.what());
|
||||||
// wxMessageBox(e.what(), "", MB_OK);
|
// wxMessageBox(e.what(), "", MB_OK);
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ", error: " << e.what() << std::endl;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ", error: " << e.what() << std::endl;
|
||||||
|
@ -1349,7 +1362,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
||||||
boost::nowide::ifstream ifs(sub_file);
|
boost::nowide::ifstream ifs(sub_file);
|
||||||
json pm;
|
json pm;
|
||||||
ifs >> pm;
|
ifs >> pm;
|
||||||
|
|
||||||
std::string strInstant = pm["instantiation"];
|
std::string strInstant = pm["instantiation"];
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",Path:" << sub_file << ",instantiation:" << strInstant;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",Path:" << sub_file << ",instantiation:" << strInstant;
|
||||||
|
|
||||||
|
@ -1358,9 +1371,9 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
||||||
std::string sT;
|
std::string sT;
|
||||||
|
|
||||||
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, sV, sT);
|
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, sV, sT);
|
||||||
if (nRet != 0) {
|
if (nRet != 0) {
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",GetFilamentInfo Failed, Vendor:" << sV << ",Type:"<< sT;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",GetFilamentInfo Failed, Vendor:" << sV << ",Type:"<< sT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OneFF["vendor"] = sV;
|
OneFF["vendor"] = sV;
|
||||||
|
|
|
@ -110,6 +110,8 @@ private:
|
||||||
|
|
||||||
//First Load
|
//First Load
|
||||||
bool bFirstComplete{false};
|
bool bFirstComplete{false};
|
||||||
|
bool m_destroy{false};
|
||||||
|
boost::thread* m_load_task{ nullptr };
|
||||||
|
|
||||||
// User Config
|
// User Config
|
||||||
bool PrivacyUse;
|
bool PrivacyUse;
|
||||||
|
|
Loading…
Reference in New Issue