FIX: structure json line break process when export configs

Jira: XXXX

Change-Id: I9b518d7363f51c39574a1e8733174ae6ad99f1c5
This commit is contained in:
maosheng.wei 2024-04-01 09:24:31 +08:00 committed by Lane.Wei
parent 791abec8e1
commit 76290b08ef
2 changed files with 15 additions and 2 deletions

View File

@ -3617,6 +3617,17 @@ wxBoxSizer *ExportConfigsDialog::create_radio_item(wxString title, wxWindow *par
return horizontal_sizer;
}
std::string ExportConfigsDialog::create_structure_file(json & structure)
{
if (structure.is_null()) return "";
ostringstream oss;
oss << std::setw(4) << structure << std::endl;
std::string bundle_structure = oss.str();
return bundle_structure;
}
mz_bool ExportConfigsDialog::initial_zip_archive(mz_zip_archive &zip_archive, const std::string &file_path)
{
mz_zip_zero_struct(&zip_archive);
@ -3865,7 +3876,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
bundle_structure["filament_config"] = filament_configs;
bundle_structure["process_config"] = process_configs;
std::string bundle_structure_str = bundle_structure.dump();
std::string bundle_structure_str = create_structure_file(bundle_structure);
status = mz_zip_writer_add_mem(&zip_archive, BUNDLE_STRUCTURE_JSON_NAME, bundle_structure_str.data(), bundle_structure_str.size(), MZ_DEFAULT_COMPRESSION);
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << " Failed to add file: " << BUNDLE_STRUCTURE_JSON_NAME;
@ -3960,7 +3971,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_
bundle_structure["printer_vendor"].push_back(j);
}
std::string bundle_structure_str = bundle_structure.dump();
std::string bundle_structure_str = create_structure_file(bundle_structure);
status = mz_zip_writer_add_mem(&zip_archive, BUNDLE_STRUCTURE_JSON_NAME, bundle_structure_str.data(), bundle_structure_str.size(), MZ_DEFAULT_COMPRESSION);
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << " Failed to add file: " << BUNDLE_STRUCTURE_JSON_NAME;

View File

@ -12,6 +12,7 @@
#include "Widgets/ComboBox.hpp"
#include "miniz.h"
#include "ParamsDialog.hpp"
#include "json_diff.hpp"
namespace Slic3r {
namespace GUI {
@ -271,6 +272,7 @@ private:
wxBoxSizer *create_button_item(wxWindow *parent);
wxBoxSizer *create_select_printer(wxWindow *parent);
wxBoxSizer *create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector<std::pair<RadioBox *, wxString>> &radiobox_list);
std::string create_structure_file(json &structure);
int initial_zip_archive(mz_zip_archive &zip_archive, const std::string &file_path);
ExportCase save_zip_archive_to_file(mz_zip_archive &zip_archive);
ExportCase save_presets_to_zip(const std::string &export_file, const std::vector<std::pair<std::string, std::string>> &config_paths);