[gnome-music/wip/jfelder/fix-smoothscale-width: 41/41] smoothscale: Prevent negative timeouts



commit 9deacddafb5330bf366520e376bbc0be35977ea8
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Jan 7 14:28:23 2019 +0100

    smoothscale: Prevent negative timeouts
    
    Smoothscale timeout depends on the scale's width and
    padding. Apparently in some configurations (maybe a custom theme or a
    custom scaling), this width can become negative. This results in a
    crash as a timeout cannot be negative.
    
    Add a max bound to ensure to ensure that the width variable cannot be
    smaller than 1.
    
    Closes: #244

 gnomemusic/widgets/smoothscale.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 6bd33448..103ff800 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -186,7 +186,7 @@ class SmoothScale(Gtk.Scale):
         width = self.get_allocated_width()
         padding = self.get_style_context().get_padding(
             Gtk.StateFlags.NORMAL)
-        width -= padding.left + padding.right
+        width = max(width - (padding.left + padding.right), 1)
 
         timeout_period = min(1000 * duration // width, 1000)
 


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