FIX: UserGuide Can not Click When Computer User name has chinese

JIRA: None
Change-Id: If50baa8c6a13eb501918fd5cdaf0ea3da7c788ef
(cherry picked from commit 4e5ccc9f2de5ac429af6541c6a8bd412848801d0)
This commit is contained in:
zorro.zhang 2024-01-18 17:45:33 +08:00 committed by Lane.Wei
parent 90e0a61576
commit 4171b3320e
1 changed files with 38 additions and 10 deletions

View File

@ -354,9 +354,12 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
{
try {
wxString strInput = evt.GetString();
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;OnRecv:" << strInput.c_str();
json j = json::parse(strInput);
wxString strCmd = j["command"];
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;
if (strCmd == "close_page") {
this->EndModal(wxID_CANCEL);
}
@ -384,8 +387,10 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
m_Res["sequence_id"] = "10001";
m_Res["response"] = m_ProfileJson;
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
//wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;request_userguide_profile:" << strJS.c_str();
wxGetApp().CallAfter([this,strJS] { RunScript(strJS); });
}
else if (strCmd == "request_custom_filaments") {
@ -482,6 +487,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
}
} catch (std::exception &e) {
// wxMessageBox(e.what(), "json Exception", MB_OK);
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Error:" << e.what();
}
wxString strAll = m_ProfileJson.dump(-1,' ',false, json::error_handler_t::ignore);
@ -968,20 +974,28 @@ bool GuideFrame::run()
int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType)
{
//GetStardardFilePath(filepath);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " GetFilamentInfo:VendorDirectory - " << VendorDirectory << ", Filepath - "<<filepath;
try {
std::string contents;
LoadFile(filepath, contents);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": Json Contents: " << contents;
json jLocal = json::parse(contents);
if (sVendor == "") {
if (jLocal.contains("filament_vendor"))
sVendor = jLocal["filament_vendor"][0];
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << filepath << " - Not Contains filament_vendor";
}
}
if (sType == "") {
if (jLocal.contains("filament_type"))
sType = jLocal["filament_type"][0];
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << filepath << " - Not Contains filament_type";
}
}
if (sVendor == "" || sType == "")
@ -989,21 +1003,29 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
if (jLocal.contains("inherits")) {
std::string FName = jLocal["inherits"];
if (!pFilaList.contains(FName))
return -1;
if (!pFilaList.contains(FName)) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "pFilaList - Not Contains inherits filaments: " << FName;
return -1;
}
std::string FPath = pFilaList[FName]["sub_path"];
wxString strNewFile = wxString::Format("%s%c%s", VendorDirectory, boost::filesystem::path::preferred_separator, FPath);
boost::filesystem::path inherits_path = boost::filesystem::absolute(w2s(strNewFile)).make_preferred();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Before Format Inherits Path: VendorDirectory - " << VendorDirectory << ", sub_path - " << FPath;
wxString strNewFile = wxString::Format("%s%c%s", wxString(VendorDirectory.c_str(), wxConvUTF8), boost::filesystem::path::preferred_separator, FPath);
boost::filesystem::path inherits_path(w2s(strNewFile));
//boost::filesystem::path nf(strNewFile.c_str());
if (boost::filesystem::exists(inherits_path))
return GetFilamentInfo(VendorDirectory,pFilaList, inherits_path.string(), sVendor, sType);
else
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " inherits File Not Exist: " << inherits_path;
return -1;
}
} else {
if (sType == "")
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << filepath << " - Not Contains inherits";
if (sType == "") {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "sType is Empty";
return -1;
}
else
sVendor = "Generic";
return 0;
@ -1055,7 +1077,7 @@ int GuideFrame::LoadProfile()
// BBS: change directories by design
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", will load config from %1%.") % bbl_bundle_path;
m_ProfileJson = json::parse("{}");
m_ProfileJson["configpath"] = Slic3r::data_dir();
//m_ProfileJson["configpath"] = Slic3r::data_dir();
m_ProfileJson["model"] = json::array();
m_ProfileJson["machine"] = json::object();
m_ProfileJson["filament"] = json::object();
@ -1497,6 +1519,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
std::string s2 = OneFF["sub_path"];
tFilaList[s1] = OneFF;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Vendor: " << strVendor <<", tFilaList Add: " << s1;
}
int nFalse = 0;
@ -1515,14 +1538,19 @@ 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;
if (strInstant == "true") {
std::string sV;
std::string sT;
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, sV, sT);
if (nRet != 0) continue;
if (nRet != 0) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",GetFilamentInfo Failed, Vendor:" << sV << ",Type:"<< sT;
continue;
}
OneFF["vendor"] = sV;
OneFF["type"] = sT;