← Back to team overview

yade-dev team mailing list archive

[svn] r1770 - trunk/lib/serialization-qt

 

Author: cosurgi
Date: 2009-05-11 18:14:12 +0200 (Mon, 11 May 2009)
New Revision: 1770

Modified:
   trunk/lib/serialization-qt/QtGUIGenerator.cpp
Log:
small fix


Modified: trunk/lib/serialization-qt/QtGUIGenerator.cpp
===================================================================
--- trunk/lib/serialization-qt/QtGUIGenerator.cpp	2009-05-08 23:47:08 UTC (rev 1769)
+++ trunk/lib/serialization-qt/QtGUIGenerator.cpp	2009-05-11 16:14:12 UTC (rev 1770)
@@ -163,16 +163,24 @@
 			}
 		}
 	}
-	Real a = boost::lexical_cast<Real>(ret);
-	Real b = boost::lexical_cast<Real>(num);
-	if(a-b == 0) // the sanitized number and original numer must be exactly the same
+	try
 	{
-		return ret;
+		Real a = boost::lexical_cast<Real>(ret);
+		Real b = boost::lexical_cast<Real>(num);
+		if(a-b == 0) // the sanitized number and original number must be exactly the same
+		{
+			return ret;
+		}
+		else
+		{
+			std::cerr << "INFO: sanitize failed: " << a << " != " << b << "\n";
+			return num; // return original numer, since they are different
+		}
 	}
-	else
+	catch(std::bad_cast&)
 	{
-		std::cerr << "INFO: sanitize failed: " << a << " != " << b << "\n";
-		return num; // return original numer, since they are different
+		std::cerr << "INFO: sanitize failed: " << ret << " != " << num << "\n";
+		return num; // oops, the number got corrupted somehow
 	}
 };