[gnome-music/wip/jfelder/fix-smoothscale-width: 3/3] smoothscale: Prevent negative timeouts
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/fix-smoothscale-width: 3/3] smoothscale: Prevent negative timeouts
- Date: Mon, 18 Feb 2019 05:22:19 +0000 (UTC)
commit 1d642c0f7a5bd7ab544b3bee212f92a73ba5d5cf
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]