[gnome-calculator] Fixed possible errors on currency conversion (bgo#750672)



commit e3d8648134fc781a9db7fb2dc4f6297ff0bcc04e
Author: Robert Roth <robert roth off gmail com>
Date:   Wed Oct 12 01:57:40 2016 +0300

    Fixed possible errors on currency conversion (bgo#750672)

 lib/currency.vala |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/lib/currency.vala b/lib/currency.vala
index 816dd64..25b432a 100644
--- a/lib/currency.vala
+++ b/lib/currency.vala
@@ -263,14 +263,16 @@ public class CurrencyManager : Object
                     if (symbol != null)
                     {
                         var c = get_currency (symbol);
-                        if (c == null)
+                        var value = mp_set_from_string (tokens[value_index]);
+                        /* Use data if we have a valid value */
+                        if (c == null && value != null)
                         {
                             debug ("Using IMF rate of %s for %s", tokens[value_index], symbol);
                             c = add_currency (symbol);
+                            value = value.reciprocal ();
+                            if (c != null)
+                                c.set_value (value);
                         }
-                        var value = mp_set_from_string (tokens[value_index]);
-                        value = value.reciprocal ();
-                        c.set_value (value);
                     }
                     else
                         warning ("Unknown currency '%s'", tokens[0]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]