From 6b7588c497ad9a6c551efad97f7a8ea58fd445bf Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 15 Feb 2012 19:31:36 +0000 Subject: (progress) limit progress bar refreshes to 3 per second max (mga#2775) --- NEWS | 2 ++ Rpmdrake/gurpm.pm | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 579a3ead..d11b4e35 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- limit progress bar refreshes to 3 per second max (mga#2775) + Version 5.27 - 10 December 2011, Thierry Vignaud - fix opening URLs in root's firefox in some cases by redefining HOME (mga#287) diff --git a/Rpmdrake/gurpm.pm b/Rpmdrake/gurpm.pm index 3a9017c9..ea77d419 100644 --- a/Rpmdrake/gurpm.pm +++ b/Rpmdrake/gurpm.pm @@ -28,6 +28,8 @@ use lib qw(/usr/lib/libDrakX); use mygtk2 qw(gtknew); #- do not import anything else, especially gtkadd() which conflicts with ugtk2 one use ugtk2 qw(:all); use base qw(ugtk2); +use Time::HiRes; +use feature 'state'; sub new { @@ -61,9 +63,12 @@ sub label { sub progress { my ($self, $fraction) = @_; + state $time; $fraction = 0 if $fraction < 0; $fraction = 1 if 1 < $fraction; $self->{progressbar}->set_fraction($fraction); + return if Time::HiRes::clock_gettime() - $time < 0.333; + $time = Time::HiRes::clock_gettime(); $self->flush; } -- cgit v1.2.1