mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 19:45:54 +08:00
Merge branch 'dk_wizard'
This commit is contained in:
commit
3735ceb624
@ -3333,17 +3333,6 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||
const auto enabled_vendors = appconfig_new.vendors();
|
||||
const auto enabled_vendors_old = app_config->vendors();
|
||||
|
||||
std::vector<std::string> used_repo_ids;
|
||||
for (const auto& vendor : enabled_vendors) {
|
||||
const auto& it = bundles.find(vendor.first);
|
||||
assert(it != bundles.end());
|
||||
const std::string repo_id = it->second.vendor_profile->repo_id;
|
||||
if (std::find(used_repo_ids.begin(), used_repo_ids.end(), repo_id) == used_repo_ids.end()) {
|
||||
used_repo_ids.emplace_back(repo_id);
|
||||
}
|
||||
}
|
||||
wxGetApp().plater()->get_preset_archive_database()->set_installed_printer_repositories(std::move(used_repo_ids));
|
||||
|
||||
bool suppress_sla_printer = model_has_multi_part_objects(wxGetApp().model());
|
||||
PrinterTechnology preferred_pt = ptAny;
|
||||
auto get_preferred_printer_technology = [enabled_vendors, enabled_vendors_old, suppress_sla_printer](const std::string& bundle_name, const Bundle& bundle) {
|
||||
@ -3577,6 +3566,36 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||
}
|
||||
}
|
||||
|
||||
// Save used repo into manifest.
|
||||
std::vector<std::string> used_repo_ids;
|
||||
for (const auto& vendor : enabled_vendors) {
|
||||
// here vendor might be empty - it causes false has_installed_printers : 1 entries in manifest.
|
||||
if (vendor.second.empty()){
|
||||
continue;
|
||||
}
|
||||
bool not_empty = false;
|
||||
for (const auto& it : vendor.second) {
|
||||
if (!it.second.empty()) {
|
||||
not_empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!not_empty) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& it = bundles.find(vendor.first);
|
||||
// This is a last resort solution of missing secret repo in manifest while some of its printers are installed.
|
||||
if (it == bundles.end()) {
|
||||
continue;
|
||||
}
|
||||
const std::string repo_id = it->second.vendor_profile->repo_id;
|
||||
if (std::find(used_repo_ids.begin(), used_repo_ids.end(), repo_id) == used_repo_ids.end()) {
|
||||
used_repo_ids.emplace_back(repo_id);
|
||||
}
|
||||
}
|
||||
wxGetApp().plater()->get_preset_archive_database()->set_installed_printer_repositories(std::move(used_repo_ids));
|
||||
|
||||
// apply materials in app_config
|
||||
for (const std::string& section_name : {AppConfig::SECTION_FILAMENTS, AppConfig::SECTION_MATERIALS})
|
||||
if (appconfig_new.has_section(section_name))
|
||||
|
@ -409,21 +409,44 @@ void PresetArchiveDatabase::set_installed_printer_repositories(const std::vector
|
||||
// set correct repos as having installed printer
|
||||
for (const std::string &used_id : used_ids) {
|
||||
// find archive with id and is used
|
||||
std::vector<std::string> selected_uuid;
|
||||
std::vector<std::string> unselected_uuid;
|
||||
for (const auto &archive : m_archive_repositories) {
|
||||
if (archive->get_manifest().id != used_id) {
|
||||
continue;
|
||||
}
|
||||
const std::string uuid = archive->get_uuid();
|
||||
|
||||
const auto& it = m_selected_repositories_uuid.find(uuid);
|
||||
assert(it != m_selected_repositories_uuid.end());
|
||||
if (it->second == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// set archive as has installed printer
|
||||
m_has_installed_printer_repositories_uuid[uuid] = true;
|
||||
if (m_selected_repositories_uuid[uuid]) {
|
||||
selected_uuid.emplace_back(uuid);
|
||||
} else {
|
||||
unselected_uuid.emplace_back(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if (selected_uuid.empty() && unselected_uuid.empty()) {
|
||||
// there is id in used_ids that is not in m_archive_repositories - BAD
|
||||
assert(true);
|
||||
continue;
|
||||
} else if (selected_uuid.size() == 1){
|
||||
// regular case
|
||||
m_has_installed_printer_repositories_uuid[selected_uuid.front()] = true;
|
||||
} else if (selected_uuid.size() > 1) {
|
||||
// this should not happen, only one repo of same id should be selected (online / local conflict)
|
||||
assert(true);
|
||||
// select first one to solve the conflict
|
||||
m_has_installed_printer_repositories_uuid[selected_uuid.front()] = true;
|
||||
// unselect the rest
|
||||
for (size_t i = 1; i < selected_uuid.size(); i++) {
|
||||
m_selected_repositories_uuid[selected_uuid[i]] = false;
|
||||
}
|
||||
} else if (selected_uuid.empty()) {
|
||||
// This is a rare case, where there are no selected repos with matching id but id has installed printers
|
||||
// Repro: install printer, unselect repo in the next run of wizard, next, cancel wizard, run wizard again and press finish.
|
||||
// Solution: Select the first unselected
|
||||
m_has_installed_printer_repositories_uuid[unselected_uuid.front()] = true;
|
||||
m_selected_repositories_uuid[unselected_uuid.front()] = true;
|
||||
}
|
||||
|
||||
}
|
||||
save_app_manifest_json();
|
||||
}
|
||||
@ -689,7 +712,7 @@ void PresetArchiveDatabase::clear_online_repos()
|
||||
{
|
||||
auto it = m_archive_repositories.begin();
|
||||
while (it != m_archive_repositories.end()) {
|
||||
// Do not clean repos with local path (local repo) and with visibility filled (secret repo)
|
||||
// Do not clean repos with local path (local repo).
|
||||
if ((*it)->get_manifest().tmp_path.empty()) {
|
||||
it = m_archive_repositories.erase(it);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user