FIX: object params variant crash
Change-Id: Ia67b98c29a0cc97f8479911ffdefb942cb6c751f Jira: none (cherry picked from commit 8bf65c0963d1ee39bba12f67f33177d4ac6d6a60)
This commit is contained in:
@@ -453,10 +453,12 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys
|
|||||||
// This is only possible if other is of DynamicConfig type.
|
// This is only possible if other is of DynamicConfig type.
|
||||||
if (auto n = opt_key.find('#'); n != std::string::npos) {
|
if (auto n = opt_key.find('#'); n != std::string::npos) {
|
||||||
auto opt_key2 = opt_key.substr(0, n);
|
auto opt_key2 = opt_key.substr(0, n);
|
||||||
auto my_opt2 = dynamic_cast<ConfigOptionVectorBase*>(this->option(opt_key2, true));
|
auto my_opt2 = dynamic_cast<ConfigOptionVectorBase*>(this->option(opt_key2));
|
||||||
|
auto other_opt = other.option(opt_key2);
|
||||||
|
if (my_opt2 == nullptr && other_opt)
|
||||||
|
my_opt2 = dynamic_cast<ConfigOptionVectorBase*>(other_opt->clone());
|
||||||
if (my_opt2) {
|
if (my_opt2) {
|
||||||
int index = std::atoi(opt_key.c_str() + n + 1);
|
int index = std::atoi(opt_key.c_str() + n + 1);
|
||||||
auto other_opt = other.option(opt_key2);
|
|
||||||
if (other_opt)
|
if (other_opt)
|
||||||
my_opt2->set_at(other_opt, index, index);
|
my_opt2->set_at(other_opt, index, index);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -527,6 +527,10 @@ std::vector<std::map<int, int>> get_extruder_ams_count(const std::vector<std::st
|
|||||||
std::vector<std::map<int, int>> extruder_ams_counts;
|
std::vector<std::map<int, int>> extruder_ams_counts;
|
||||||
for (const std::string& str : strs) {
|
for (const std::string& str : strs) {
|
||||||
std::map<int, int> ams_count_info;
|
std::map<int, int> ams_count_info;
|
||||||
|
if (str.empty()) {
|
||||||
|
extruder_ams_counts.emplace_back(ams_count_info);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::vector<std::string> ams_infos;
|
std::vector<std::string> ams_infos;
|
||||||
boost::algorithm::split(ams_infos, str, boost::algorithm::is_any_of("|"));
|
boost::algorithm::split(ams_infos, str, boost::algorithm::is_any_of("|"));
|
||||||
for (const std::string& ams_info : ams_infos) {
|
for (const std::string& ams_info : ams_infos) {
|
||||||
|
|||||||
@@ -1015,8 +1015,8 @@ void CheckBox::set_value(const boost::any& value, bool change_event)
|
|||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
if (m_opt.nullable) {
|
if (m_opt.nullable) {
|
||||||
const bool is_value_unsigned_char = value.type() == typeid(unsigned char);
|
const bool is_value_unsigned_char = value.type() == typeid(unsigned char);
|
||||||
m_is_na_val = is_value_unsigned_char &&
|
m_is_na_val = value.empty() || (is_value_unsigned_char &&
|
||||||
boost::any_cast<unsigned char>(value) == ConfigOptionBoolsNullable::nil_value();
|
boost::any_cast<unsigned char>(value) == ConfigOptionBoolsNullable::nil_value());
|
||||||
if (!m_is_na_val)
|
if (!m_is_na_val)
|
||||||
m_last_meaningful_value = is_value_unsigned_char ? value : static_cast<unsigned char>(boost::any_cast<bool>(value));
|
m_last_meaningful_value = is_value_unsigned_char ? value : static_cast<unsigned char>(boost::any_cast<bool>(value));
|
||||||
|
|
||||||
|
|||||||
@@ -2829,7 +2829,9 @@ void TabPrintModel::update_model_config()
|
|||||||
//update();
|
//update();
|
||||||
if (!m_null_keys.empty()) {
|
if (!m_null_keys.empty()) {
|
||||||
if (m_active_page) {
|
if (m_active_page) {
|
||||||
for (auto k : m_null_keys) {
|
auto null_keys = m_null_keys;
|
||||||
|
filter_diff_option(null_keys);
|
||||||
|
for (auto k : null_keys) {
|
||||||
auto f = m_active_page->get_field(k);
|
auto f = m_active_page->get_field(k);
|
||||||
if (f)
|
if (f)
|
||||||
f->set_value(boost::any(), false);
|
f->set_value(boost::any(), false);
|
||||||
@@ -2862,7 +2864,9 @@ void TabPrintModel::activate_selected_page(std::function<void()> throw_if_cancel
|
|||||||
{
|
{
|
||||||
TabPrint::activate_selected_page(throw_if_canceled);
|
TabPrint::activate_selected_page(throw_if_canceled);
|
||||||
if (m_active_page) {
|
if (m_active_page) {
|
||||||
for (auto k : m_null_keys) {
|
auto null_keys = m_null_keys;
|
||||||
|
filter_diff_option(null_keys);
|
||||||
|
for (auto k : null_keys) {
|
||||||
auto f = m_active_page->get_field(k);
|
auto f = m_active_page->get_field(k);
|
||||||
if (f)
|
if (f)
|
||||||
f->set_value(boost::any(), false);
|
f->set_value(boost::any(), false);
|
||||||
@@ -2896,6 +2900,7 @@ void TabPrintModel::on_value_change(const std::string& opt_id, const boost::any&
|
|||||||
bool set = true; // *m_config->option(k) != *m_prints.get_selected_preset().config.option(k) || inull != m_null_keys.end();
|
bool set = true; // *m_config->option(k) != *m_prints.get_selected_preset().config.option(k) || inull != m_null_keys.end();
|
||||||
auto tab_opt = dynamic_cast<ConfigOptionVectorBase *>(m_config->option(opt_key));
|
auto tab_opt = dynamic_cast<ConfigOptionVectorBase *>(m_config->option(opt_key));
|
||||||
static std::map<ConfigOptionType, ConfigOptionVectorBase const *> null_vecs {
|
static std::map<ConfigOptionType, ConfigOptionVectorBase const *> null_vecs {
|
||||||
|
{coBools, new ConfigOptionBoolsNullable(std::initializer_list<unsigned char>{ConfigOptionBoolsNullable::nil_value()})},
|
||||||
{coInts, new ConfigOptionIntsNullable(1, ConfigOptionIntsNullable::nil_value())},
|
{coInts, new ConfigOptionIntsNullable(1, ConfigOptionIntsNullable::nil_value())},
|
||||||
{coFloats, new ConfigOptionFloatsNullable(1, ConfigOptionFloatsNullable::nil_value())},
|
{coFloats, new ConfigOptionFloatsNullable(1, ConfigOptionFloatsNullable::nil_value())},
|
||||||
{coPercents, new ConfigOptionPercentsNullable(1, ConfigOptionPercentsNullable::nil_value())},
|
{coPercents, new ConfigOptionPercentsNullable(1, ConfigOptionPercentsNullable::nil_value())},
|
||||||
@@ -2952,7 +2957,15 @@ void TabPrintModel::on_value_change(const std::string& opt_id, const boost::any&
|
|||||||
void TabPrintModel::reload_config()
|
void TabPrintModel::reload_config()
|
||||||
{
|
{
|
||||||
TabPrint::reload_config();
|
TabPrint::reload_config();
|
||||||
auto keys = m_config_manipulation.applying_keys();
|
if (m_active_page) {
|
||||||
|
auto null_keys = m_null_keys;
|
||||||
|
filter_diff_option(null_keys);
|
||||||
|
for (auto k : null_keys) {
|
||||||
|
auto f = m_active_page->get_field(k);
|
||||||
|
if (f) f->set_value(boost::any(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto keys = m_config_manipulation.applying_keys();
|
||||||
bool super_changed = false;
|
bool super_changed = false;
|
||||||
for (auto & k : keys) {
|
for (auto & k : keys) {
|
||||||
if (has_key(k)) {
|
if (has_key(k)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user