Fix a crash issue then exporting preset bundle (#8525)
fix crashes when finding base preset
This commit is contained in:
parent
24522fdaf7
commit
70dfdb95a9
3 changed files with 10 additions and 2 deletions
|
@ -2461,7 +2461,7 @@ const Preset *PresetCollection::get_preset_base(const Preset &child) const
|
|||
// Handle user preset
|
||||
if (child.inherits().empty())
|
||||
return &child; // this is user root
|
||||
auto inherits = find_preset(child.inherits());
|
||||
auto inherits = find_preset2(child.inherits(),true);
|
||||
return inherits ? get_preset_base(*inherits) : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -610,7 +610,10 @@ public:
|
|||
// Orca: find preset, if not found, keep searching in the renamed history. This is function should only be used when find
|
||||
// system(parent) presets for custom preset.
|
||||
Preset* find_preset2(const std::string& name, bool auto_match = true);
|
||||
|
||||
const Preset* find_preset2(const std::string& name, bool auto_match = true) const
|
||||
{
|
||||
return const_cast<PresetCollection*>(this)->find_preset2(name, auto_match);
|
||||
}
|
||||
size_t first_visible_idx() const;
|
||||
// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible.
|
||||
// If one of the prefered_alternates is compatible, select it.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "CreatePresetsDialog.hpp"
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
@ -4240,6 +4241,10 @@ void ExportConfigsDialog::data_init()
|
|||
Preset *new_filament_preset = new Preset(filament_preset);
|
||||
const Preset *base_filament_preset = preset_bundle.filaments.get_preset_base(*new_filament_preset);
|
||||
|
||||
if (base_filament_preset == nullptr) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " Failed to find base preset";
|
||||
continue;
|
||||
}
|
||||
std::string filament_preset_name = base_filament_preset->name;
|
||||
std::string machine_name = get_machine_name(filament_preset_name);
|
||||
m_filament_name_to_presets[get_filament_name(filament_preset_name)].push_back(std::make_pair(get_vendor_name(machine_name), new_filament_preset));
|
||||
|
|
Loading…
Reference in a new issue