Files
slic3r/0001-Fixed-return-value-for-deserialize-implementations.-.patch

74 lines
2.4 KiB
Diff
Raw Permalink Normal View History

From e91cf55b7379fc0c7dd1c663b762deb0dedadea3 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
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 d1c51ac..6ffd9c9 100644
--- a/xs/src/libslic3r/Config.cpp
+++ b/xs/src/libslic3r/Config.cpp
@@ -23,7 +23,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 49e999b..b8769a1 100644
--- a/xs/src/libslic3r/Config.hpp
+++ b/xs/src/libslic3r/Config.hpp
@@ -65,7 +65,8 @@ class ConfigOptionFloat : public ConfigOption
bool deserialize(std::string str) {
std::istringstream iss(str);
- return iss >> this->value;
+ iss >> this->value;
+ return !iss.fail();
};
};
@@ -124,7 +125,8 @@ class ConfigOptionInt : public ConfigOption
bool deserialize(std::string str) {
std::istringstream iss(str);
- return iss >> this->value;
+ iss >> this->value;
+ return !iss.fail();
};
};
@@ -249,7 +251,8 @@ class ConfigOptionPercent : public ConfigOption
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();
};
};
@@ -279,7 +282,8 @@ class ConfigOptionFloatOrPercent : public ConfigOption
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();
};
};
--
2.10.0