summarylogtreecommitdiffstats
path: root/6e5938c8330b5bdb6b85c3ca8dc188605ee56b98.patch
blob: 41721eac73a0a69902cac206a3f8c74ff6241839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From 6e5938c8330b5bdb6b85c3ca8dc188605ee56b98 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 deb7d5c..9194548 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 9237535..99cc02f 100644
--- a/xs/src/libslic3r/Config.hpp
+++ b/xs/src/libslic3r/Config.hpp
@@ -87,7 +87,8 @@ class ConfigOptionFloat : public ConfigOptionSingle<double>
     
     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<int>
     
     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();
     };
 };