Bug 450015 - KDialog progress bar doesn't go to 100%
Summary: KDialog progress bar doesn't go to 100%
Status: RESOLVED FIXED
Alias: None
Product: kdialog
Classification: Applications
Component: general (show other bugs)
Version: 21.08.3
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: shenlebantongying
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-11 15:15 UTC by Nicholas Redgrave
Modified: 2023-01-15 08:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
KDialog progress test script (933 bytes, application/x-shellscript)
2022-02-11 15:15 UTC, Nicholas Redgrave
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Redgrave 2022-02-11 15:15:15 UTC
Created attachment 146582 [details]
KDialog progress test script

SUMMARY
***
KDialog progress bar never shows a full bar and "100%" indication.

***


STEPS TO REPRODUCE
1.  Run attached script in a konsole window.

OBSERVED RESULT
Progress bar goes up to 66% and shows "66%" in text and then goes blank.

EXPECTED RESULT
Progress bar becomes full and shows "100%" in text.

SOFTWARE/OS VERSIONS

Operating System: Fedora Linux 35
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.5-200.fc35.x86_64 (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION

The konsole window scrolls because qdbus emits carriage returns during the script.  That can be fixed with liberal use of "> /dev/null" but it is annoying.

The example uses two different methods of setting the progress bar value:

qdbus $dbusRef Set "" value 1

and

qdbus $dbusRef value 1

The first comes from the "Shell Scripting with KDE Dialogs" page at:
https://develop.kde.org/deploy/kdialog/

and the second style is from the "progressdemo" example in the KDialog source repository "tests" directory.
I do not know which style is best or whether there is any difference between the two.
Comment 1 ticket.kde.djr4kjpch5320z5k 2022-03-22 05:54:33 UTC
It's like that for quite some time.
I thought it was because I have scaling but I was wrong.
Comment 2 Duncan 2022-06-27 01:07:26 UTC
Not sure kdialog's actually actively maintained any longer (tho it is kept building and working, including running as a native wayland binary and current qt6 porting work).  For more on that see bug #455994 which I just filed: https://bugs.kde.org/show_bug.cgi?id=455994

Meanwhile, I've not had occasion to use --progressbar and wasn't aware of this bug until the pre-bug-file search for the above, but as it hasn't been mentioned yet, kdialog should now ship with a kdialog_progress_helper binary (depending on your distro packaging, of course), which I /assume/ does what its name indicates, and that it's "the modern way" to deal with kdialog progressbars.

Unfortunately it's entirely undocumented AFAICT, nothing on the tutorial (which uses the bare kdialog --progressbar), nothing in the README, no manpages or kde handbook entries for kdialog at all, and it doesn't even have the --help output that kdialog itself has.  And it's an elf binary so can't just open it in a text editor like a script to see what it does. So it seems it's "read the source" (if you can) or try your luck with experiments. =:^(
Comment 3 shenlebantongying 2023-01-13 13:13:05 UTC
I just hunted down the problem, and a fix is here https://invent.kde.org/utilities/kdialog/-/merge_requests/16

Just hoping someone can merge it soon.
Comment 4 Bharadwaj Raju 2023-01-15 08:05:31 UTC
Git commit 071216ef09c80c07027bf37db216d0b90d2bfbf3 by Bharadwaj Raju, on behalf of shenleban tongying.
Committed on 15/01/2023 at 08:05.
Pushed by bharadwaj-raju into branch 'master'.

fix: disable progressdialog's autoreset

`QProgressDialog` has a default `autoreset` turned on which will reset the progress bar when max value reached and it will prevents 100% being shown

The source of truth is here: https://github.com/qt/qtbase/blame/bd99d02123dcb9e406d06605fe0fa8a9d2cea3a4/src/widgets/dialogs/qprogressdialog.cpp#L655-L657

I don't know why `QProgressDialog` have `autoreset` while `QProgressBar` don't, but it is there for at least 10 years.

To test this:
```
dbusRef=`kdialog --progressbar "init val" 3`
qdbus $dbusRef Set "" value 1
sleep 1
qdbus $dbusRef Set "" value 2
sleep 1
qdbus $dbusRef Set "" value 3
sleep 1
```

M  +1    -0    src/progressdialog.cpp

https://invent.kde.org/utilities/kdialog/commit/071216ef09c80c07027bf37db216d0b90d2bfbf3
Comment 5 Bharadwaj Raju 2023-01-15 08:59:12 UTC
Git commit 1a808ac2b8a007c6cfff777a69d04f15b99b9f4c by Bharadwaj Raju, on behalf of shenleban tongying.
Committed on 15/01/2023 at 08:59.
Pushed by bharadwaj-raju into branch 'release/22.12'.

fix: disable progressdialog's autoreset

`QProgressDialog` has a default `autoreset` turned on which will reset the progress bar when max value reached and it will prevents 100% being shown

The source of truth is here: https://github.com/qt/qtbase/blame/bd99d02123dcb9e406d06605fe0fa8a9d2cea3a4/src/widgets/dialogs/qprogressdialog.cpp#L655-L657

I don't know why `QProgressDialog` have `autoreset` while `QProgressBar` don't, but it is there for at least 10 years.

To test this:
```
dbusRef=`kdialog --progressbar "init val" 3`
qdbus $dbusRef Set "" value 1
sleep 1
qdbus $dbusRef Set "" value 2
sleep 1
qdbus $dbusRef Set "" value 3
sleep 1
```


(cherry picked from commit 071216ef09c80c07027bf37db216d0b90d2bfbf3)

M  +1    -0    src/progressdialog.cpp

https://invent.kde.org/utilities/kdialog/commit/1a808ac2b8a007c6cfff777a69d04f15b99b9f4c