Use PBD::string_to/to_string when de/serializing in AutomationList class
authorTim Mayberry <mojofunk@gmail.com>
Thu, 8 Sep 2016 00:19:12 +0000 (10:19 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 18 Apr 2017 23:37:00 +0000 (09:37 +1000)
This avoids requiring a LocaleGuard to get the correct numeric formatting and
saves/restores the automation data to the precision required for roundtrip
equality.

libs/ardour/automation_list.cc

index ff22dae5dab36bd61b9bb88c70b06f10ed5fb621..c397323767ee435c55c40f3ceb64cee87a1905da 100644 (file)
@@ -347,12 +347,10 @@ AutomationList::serialize_events ()
        XMLNode* node = new XMLNode (X_("events"));
        stringstream str;
 
-       str.precision(15);  //10 digits is enough digits for 24 hours at 96kHz
-
        for (iterator xx = _events.begin(); xx != _events.end(); ++xx) {
-               str << (double) (*xx)->when;
+               str << PBD::to_string ((*xx)->when);
                str << ' ';
-               str <<(double) (*xx)->value;
+               str << PBD::to_string ((*xx)->value);
                str << '\n';
        }
 
@@ -384,17 +382,19 @@ AutomationList::deserialize_events (const XMLNode& node)
 
        stringstream str (content_node->content());
 
+       std::string x_str;
+       std::string y_str;
        double x;
        double y;
        bool ok = true;
 
        while (str) {
-               str >> x;
-               if (!str) {
+               str >> x_str;
+               if (!str || !PBD::string_to<double> (x_str, x)) {
                        break;
                }
-               str >> y;
-               if (!str) {
+               str >> y_str;
+               if (!str || !PBD::string_to<double> (y_str, y)) {
                        ok = false;
                        break;
                }