mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 11:05:58 +08:00
Improvement of previous commit:
- use boost::nowide instead of WinAPI for the encoding conversion - only add the node when it is not empty
This commit is contained in:
parent
de1785760c
commit
8915d8bc91
@ -485,21 +485,18 @@ static std::string generate_system_info_json()
|
|||||||
pt::ptree blacklisted_node;
|
pt::ptree blacklisted_node;
|
||||||
std::vector<std::wstring> blacklisted_libraries;
|
std::vector<std::wstring> blacklisted_libraries;
|
||||||
BlacklistedLibraryCheck::get_instance().get_blacklisted(blacklisted_libraries);
|
BlacklistedLibraryCheck::get_instance().get_blacklisted(blacklisted_libraries);
|
||||||
for (const std::wstring& str : blacklisted_libraries) {
|
for (const std::wstring& wstr : blacklisted_libraries) {
|
||||||
std::string utf8;
|
std::string utf8 = boost::nowide::narrow(wstr);
|
||||||
const size_t num_bytes = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), 0, 0, 0);
|
if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) {
|
||||||
utf8.resize(num_bytes);
|
// Remove anything before last backslash so we don't send the path to the DLL.
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), num_bytes, 0, 0)) {
|
utf8.erase(0, last_bs_pos + 1);
|
||||||
if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) {
|
|
||||||
// Remove anything before last backslash so we don't send the path to the DLL.
|
|
||||||
utf8.erase(0, last_bs_pos + 1);
|
|
||||||
}
|
|
||||||
pt::ptree node; // Create an unnamed node containing the value
|
|
||||||
node.put("", utf8);
|
|
||||||
blacklisted_node.push_back(std::make_pair("", node)); // Add this node to the list.
|
|
||||||
}
|
}
|
||||||
|
pt::ptree node; // Create an unnamed node containing the value
|
||||||
|
node.put("", utf8);
|
||||||
|
blacklisted_node.push_back(std::make_pair("", node)); // Add this node to the list.
|
||||||
}
|
}
|
||||||
data_node.add_child("Blacklisted libraries", blacklisted_node);
|
if (! blacklisted_libraries.empty())
|
||||||
|
data_node.add_child("Blacklisted libraries", blacklisted_node);
|
||||||
}
|
}
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user