mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-26 16:13:58 -06:00
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:
parent
5e79e9196f
commit
cf0c5624a1
2 changed files with 29 additions and 14 deletions
|
@ -48,7 +48,7 @@ static wxString update_custom_filaments()
|
|||
json m_CustomFilaments = json::array();
|
||||
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::vector<std::pair<std::string, std::string>> need_sort;
|
||||
bool need_delete_some_filament = false;
|
||||
for (std::pair<std::string, std::vector<Preset const *>> filament_id_to_presets : temp_filament_id_to_presets) {
|
||||
|
@ -72,7 +72,7 @@ static wxString update_custom_filaments()
|
|||
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_name.empty()) {
|
||||
std::string preset_name = preset->name;
|
||||
size_t index_at = preset_name.find(" @");
|
||||
|
@ -132,7 +132,7 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
|
|||
}
|
||||
m_browser->Hide();
|
||||
m_browser->SetSize(0, 0);
|
||||
|
||||
|
||||
SetSizer(topsizer);
|
||||
|
||||
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
||||
|
@ -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,15 +302,16 @@ 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;
|
||||
}
|
||||
|
||||
m_browser->Show();
|
||||
Layout();
|
||||
|
||||
|
||||
wxString NewUrl = evt.GetURL();
|
||||
|
||||
UpdateState();
|
||||
|
@ -929,9 +936,9 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
|||
if (jLocal.contains("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;
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string FPath = pFilaList[FName]["sub_path"];
|
||||
|
@ -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,12 +1064,14 @@ 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));
|
||||
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
||||
if (!m_destroy)
|
||||
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
||||
|
||||
//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());
|
||||
// wxMessageBox(e.what(), "", MB_OK);
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ", error: " << e.what() << std::endl;
|
||||
|
@ -1281,7 +1294,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
std::string sub_file = sub_path.string();
|
||||
LoadFile(sub_file, contents);
|
||||
json pm = json::parse(contents);
|
||||
|
||||
|
||||
std::string strInstant = pm["instantiation"];
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",Path:" << sub_file << ",instantiation?" << strInstant;
|
||||
|
||||
|
@ -1290,9 +1303,9 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
std::string 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;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
OneFF["vendor"] = sV;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue