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



commit 5c0b3e93a07a2efff45b68b7a076bebb530fee51
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 ffc2a6a..f400353 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]