[pygobject] Fix wrong minimum checking in float properties



commit 408b2186aea58a41ec26b9d0ca29ecd42df5ef7e
Author: Paul Pogonyshev <pogonyshev gmx net>
Date:   Sun Nov 22 18:22:23 2009 +0200

    Fix wrong minimum checking in float properties
    
    Bug #587637.  Test the fix.

 gobject/propertyhelper.py |    5 +++--
 tests/test_properties.py  |    6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gobject/propertyhelper.py b/gobject/propertyhelper.py
index 216ceb2..e299273 100644
--- a/gobject/propertyhelper.py
+++ b/gobject/propertyhelper.py
@@ -224,10 +224,11 @@ class property(object):
         ptype = self.type
         if ptype in [TYPE_UINT, TYPE_ULONG, TYPE_UINT64]:
             return 0
+        # Remember that G_MINFLOAT and G_MINDOUBLE are something different.
         elif ptype == TYPE_FLOAT:
-            return G_MINFLOAT
+            return -G_MAXFLOAT
         elif ptype == TYPE_DOUBLE:
-            return G_MINDOUBLE
+            return -G_MAXDOUBLE
         elif ptype == TYPE_INT:
             return G_MININT
         elif ptype == TYPE_LONG:
diff --git a/tests/test_properties.py b/tests/test_properties.py
index e3be865..ccfcb34 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -366,5 +366,11 @@ class TestProperty(unittest.TestCase):
         else:
             raise AssertionError
 
+    # Bug 587637.
+    def test_float_min(self):
+        gobject.property(type=float, minimum=-1)
+        gobject.property(type=gobject.TYPE_FLOAT, minimum=-1)
+        gobject.property(type=gobject.TYPE_DOUBLE, minimum=-1)
+
 if __name__ == '__main__':
     unittest.main()



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