From 6e5938c8330b5bdb6b85c3ca8dc188605ee56b98 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 13 Mar 2016 15:25:50 +0100 Subject: [PATCH] Fixed return value for deserialize() implementations. #3250 --- xs/src/libslic3r/Config.cpp | 5 ++++- xs/src/libslic3r/Config.hpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index deb7d5c7e..9194548c7 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -63,7 +63,10 @@ ConfigBase::apply(const ConfigBase &other, bool ignore_nonexistent) { // not the most efficient way, but easier than casting pointers to subclasses bool res = my_opt->deserialize( other.option(*it)->serialize() ); - if (!res) CONFESS("Unexpected failure when deserializing serialized value"); + if (!res) { + std::string error = "Unexpected failure when deserializing serialized value for " + *it; + CONFESS(error.c_str()); + } } } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 9237535e2..99cc02fb0 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -87,7 +87,8 @@ class ConfigOptionFloat : public ConfigOptionSingle bool deserialize(std::string str) { std::istringstream iss(str); - return iss >> this->value; + iss >> this->value; + return !iss.fail(); }; }; @@ -145,7 +146,8 @@ class ConfigOptionInt : public ConfigOptionSingle bool deserialize(std::string str) { std::istringstream iss(str); - return iss >> this->value; + iss >> this->value; + return !iss.fail(); }; }; @@ -268,7 +270,8 @@ class ConfigOptionPercent : public ConfigOptionFloat bool deserialize(std::string str) { // don't try to parse the trailing % since it's optional std::istringstream iss(str); - return iss >> this->value; + iss >> this->value; + return !iss.fail(); }; }; @@ -307,7 +310,8 @@ class ConfigOptionFloatOrPercent : public ConfigOptionPercent bool deserialize(std::string str) { this->percent = str.find_first_of("%") != std::string::npos; std::istringstream iss(str); - return iss >> this->value; + iss >> this->value; + return !iss.fail(); }; };