Bug 507443

Summary: Progress bar cancellation cannot be detected in script
Product: [Applications] kdialog Reporter: burneddi
Component: generalAssignee: Brad Hards <bradh>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description burneddi 2025-07-24 14:01:40 UTC
SUMMARY
kdialog --progressbar can be cancelled by the user, but when it is, this is difficult to detect from a script. The way described in the documentation of querying the wasCancelled property from DBus does not work, because when the user clicks cancel, the progress bar closes, which includes closing its DBus service. It is also difficult if not impossible to get the exit code of the progress bar process itself, because it forks itself and cannot be `wait`ed on.

STEPS TO REPRODUCE
Try this example from the docs https://develop.kde.org/docs/administration/kdialog/#--progressbar-dialog-box-example-with-cancel

dbusRef=`kdialog --progressbar "Press Cancel at Any time" 10`
qdbus $dbusRef showCancelButton true

until test "true" = `qdbus $dbusRef wasCancelled`; do
 sleep 1
 inc=$((`qdbus $dbusRef Get "" "value"` + 1))
 qdbus $dbusRef Set "" "value" $inc;
done

qdbus $dbusRef close

OBSERVED RESULT
Clicking Cancel makes the script throw a bunch of errors:

Cannot find '.Get' in object /ProgressDialog at org.kde.kdialog-2655344
Cannot find '.Set' in object /ProgressDialog at org.kde.kdialog-2655344
Service 'org.kde.kdialog-2655344' does not exist.
./test.sh: line 6: test: true: unary operator expected


EXPECTED RESULT
Clicking cancel stops the script.



ADDITIONAL INFORMATION