mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-19 23:19:14 +08:00
FIX:add "read fail" deal for bambuStudio.conf
jira: STUDIO-10215? Change-Id: Ib6dca514a43f3c91948df56195ba323aa9ce308e
This commit is contained in:
parent
751aece03e
commit
62fff9dadf
@ -482,12 +482,20 @@ std::string AppConfig::load()
|
|||||||
std::string error_message;
|
std::string error_message;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ifs.open(AppConfig::loading_path());
|
auto path = AppConfig::loading_path();
|
||||||
|
ifs.open(path);
|
||||||
|
if (!ifs.is_open()) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "AppConfig::load() open fail:" << AppConfig::loading_path();
|
||||||
|
return "Line break format may be incorrect.";
|
||||||
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
std::stringstream input_stream;
|
std::stringstream input_stream;
|
||||||
input_stream << ifs.rdbuf();
|
input_stream << ifs.rdbuf();
|
||||||
std::string total_string = input_stream.str();
|
std::string total_string = input_stream.str();
|
||||||
|
if (total_string.empty()) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "AppConfig::load() read fail:" << AppConfig::loading_path();
|
||||||
|
return "read fail.";
|
||||||
|
} else {
|
||||||
size_t last_pos = total_string.find_last_of('}');
|
size_t last_pos = total_string.find_last_of('}');
|
||||||
std::string left_string = total_string.substr(0, last_pos + 1);
|
std::string left_string = total_string.substr(0, last_pos + 1);
|
||||||
// skip the "\n"
|
// skip the "\n"
|
||||||
@ -495,10 +503,12 @@ std::string AppConfig::load()
|
|||||||
|
|
||||||
std::string md5_str = appconfig_md5_hash_line({left_string.data()});
|
std::string md5_str = appconfig_md5_hash_line({left_string.data()});
|
||||||
// Verify the checksum of the config file without taking just for debugging purpose.
|
// Verify the checksum of the config file without taking just for debugging purpose.
|
||||||
if (md5_str != right_string)
|
if (md5_str != right_string) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "The configuration file " << AppConfig::loading_path() <<
|
BOOST_LOG_TRIVIAL(info) << "The configuration file " << AppConfig::loading_path()
|
||||||
" has a wrong MD5 checksum or the checksum is missing. This may indicate a file corruption or a harmless user edit.";
|
<< " has a wrong MD5 checksum or the checksum is missing. This may indicate a file corruption or a harmless user edit.";
|
||||||
|
}
|
||||||
j = json::parse(left_string);
|
j = json::parse(left_string);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ifs >> j;
|
ifs >> j;
|
||||||
#endif
|
#endif
|
||||||
|
@ -794,6 +794,10 @@ ConfigSubstitutions ConfigBase::load_from_json(const std::string &file, ForwardC
|
|||||||
|
|
||||||
int ConfigBase::load_from_json(const std::string &file, ConfigSubstitutionContext& substitution_context, bool load_inherits_to_config, std::map<std::string, std::string>& key_values, std::string& reason)
|
int ConfigBase::load_from_json(const std::string &file, ConfigSubstitutionContext& substitution_context, bool load_inherits_to_config, std::map<std::string, std::string>& key_values, std::string& reason)
|
||||||
{
|
{
|
||||||
|
if (!boost::filesystem::exists(file)) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("%1% file not exist.") % file;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
json j;
|
json j;
|
||||||
std::list<std::string> different_settings_append;
|
std::list<std::string> different_settings_append;
|
||||||
std::string new_support_style;
|
std::string new_support_style;
|
||||||
|
@ -3676,6 +3676,10 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_vendor_configs_
|
|||||||
for (auto& machine_model : machine_model_subfiles)
|
for (auto& machine_model : machine_model_subfiles)
|
||||||
{
|
{
|
||||||
std::string subfile = path + "/" + vendor_name + "/" + machine_model.second;
|
std::string subfile = path + "/" + vendor_name + "/" + machine_model.second;
|
||||||
|
if (!boost::filesystem::exists(subfile)) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("%1% file not exist.") % subfile;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
VendorProfile::PrinterModel model;
|
VendorProfile::PrinterModel model;
|
||||||
model.id = machine_model.first;
|
model.id = machine_model.first;
|
||||||
try {
|
try {
|
||||||
|
@ -2372,8 +2372,7 @@ void GUI_App::init_app_config()
|
|||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__
|
||||||
<< "Configuration file may be corrupted and is not able to be parsed.Please delete the file and try again.";
|
<< "Configuration file may be corrupted and is not able to be parsed.Please delete the file and try again.";
|
||||||
throw Slic3r::RuntimeError(
|
throw Slic3r::RuntimeError(
|
||||||
_u8L("BambuStudio configuration file may be corrupted and is not able to be parsed."
|
_u8L("BambuStudio configuration file read failed. Please manually backup and delete it, and then restart BambuStudio software.") +
|
||||||
"Please delete the file and try again.") +
|
|
||||||
"\n\n" + app_config->config_path() + "\n\n" + error);
|
"\n\n" + app_config->config_path() + "\n\n" + error);
|
||||||
}
|
}
|
||||||
// Save orig_version here, so its empty if no app_config existed before this run.
|
// Save orig_version here, so its empty if no app_config existed before this run.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user