Tk Source Code

View Ticket
Login
Ticket UUID: ef1bfef57e05099e93f1eb0960e658def076e424
Title: Error in computing return value of AnimationEnabled for ttk progress bar
Type: Bug Version: 9.0.1
Submitter: marc_culler Created on: 2025-03-06 03:09:54
Subsystem: 88. Themed Tk Assigned To: marc_culler
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-03-06 14:17:32
Resolution: Fixed Closed By: marc_culler
    Closed on: 2025-03-06 14:17:32
Description:

I noticed an amazing bug in the implementation of the ttk progress bar when I was looking into [7e28ef577a]. When the loop incrementing the progress bar reached the end, the progress bar was rapidly redisplayed even though nothing was changing. (The value at the end of the loop was 99.) It turned out that AnimationEnabled was returning 1 even though the progress bar was determinate. The cause was a misplaced parenthesis dating back to 2006.

The effect is to make any determinate progress bar be animated almost all of the time. This may explain, at least partly, the reports that progress bars significantly increase CPU usage even when they are not doing anything.

Here is the problematic code:

    return pb->progress.period > 0
	&& value > 0.0
	&& (   value < maximum
	    || pb->progress.mode == TTK_PROGRESSBAR_INDETERMINATE);

The correct code (with extra parentheses for clarity) would be:

    return (pb->progress.period > 0 && value > 0.0 && value < maximum)
	|| (pb->progress.mode == TTK_PROGRESSBAR_INDETERMINATE);

User Comments: marc_culler (claiming to be Marc Culler) added on 2025-03-06 14:17:32:
I think that works.  I will close this now.

marc_culler (claiming to be Marc Culler) added on 2025-03-06 05:18:33:
This turns out to be more complicated than I expected.

First, the manual says that the -period option is only available on Aqua.

Second, the aqua theme sets the default value of the period to 100.

So my proposed fix will not stop the animation.

I think this is left over from macOS 10.6 and older which fetured an
animated barber pole progress bar.  The period determined how fast the
barber pole spun.  Modern macs animate the indeterminate progress bar,
but not the determinate ones.  I am going to change the code so that
the animation only occurs for indeterminate progress bars with positive
period.