From 9f2cd347e37e46c4b5a2cb1871a9d26fce3abc74 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 21 Sep 2018 23:00:49 +0200 Subject: [PATCH] Fix of a set method to make ConfigOptionEnum compatible with ConfigOptionEnumGeneric. --- src/libslic3r/Config.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 2704bbcf3..e8ed43356 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -810,6 +810,14 @@ public: ConfigOption* clone() const override { return new ConfigOptionEnum(*this); } ConfigOptionEnum& operator=(const ConfigOption *opt) { this->set(opt); return *this; } bool operator==(const ConfigOptionEnum &rhs) const { return this->value == rhs.value; } + int getInt() const override { return (int)this->value; } + + void set(const ConfigOption *rhs) override { + if (rhs->type() != this->type()) + throw std::runtime_error("ConfigOptionEnum: Assigning an incompatible type"); + // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum + this->value = (T)rhs->getInt(); + } std::string serialize() const override { @@ -879,6 +887,13 @@ public: ConfigOptionEnumGeneric& operator=(const ConfigOption *opt) { this->set(opt); return *this; } bool operator==(const ConfigOptionEnumGeneric &rhs) const { return this->value == rhs.value; } + void set(const ConfigOption *rhs) override { + if (rhs->type() != this->type()) + throw std::runtime_error("ConfigOptionEnumGeneric: Assigning an incompatible type"); + // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum + this->value = rhs->getInt(); + } + std::string serialize() const override { for (const auto &kvp : *this->keys_map)