| Summary: | KFormat::formatDuration returns different results with ms large | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-kcoreaddons | Reporter: | Safa Alfulaij <safa1996alfulaij> |
| Component: | general | Assignee: | Michael Pyne <mpyne> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | kde, kdelibs-bugs-null, nate |
| Priority: | NOR | Keywords: | junior-jobs |
| Version First Reported In: | 5.48.0 | ||
| Target Milestone: | --- | ||
| Platform: | Arch Linux | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/kcoreaddons/ea2779611800e72b516f400abf18aa8ef4abfaec | Version Fixed/Implemented In: | 5.49.0 |
| Sentry Crash Report: | |||
Currently uses qRound, which returns int, but either should use qRound64 (and double instead of qreal), or just use int arithmetic for rounding, e.g. ((x + 50) / 100) * 100 will round to multiple of 100. https://cgit.kde.org/kcoreaddons.git/tree/src/lib/util/kformatprivate.cpp#n332 Git commit ea2779611800e72b516f400abf18aa8ef4abfaec by Sune Vuorela. Committed on 03/08/2018 at 16:01. Pushed by sune into branch 'master'. Fix overflow in rounding code Summary: qRound works with int. Test Plan: add unit tests Reviewers: cfeck, safaalfulaij Reviewed By: cfeck, safaalfulaij Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14565 M +11 -0 autotests/kformattest.cpp M +2 -2 src/lib/util/kformatprivate.cpp https://commits.kde.org/kcoreaddons/ea2779611800e72b516f400abf18aa8ef4abfaec |
When you use KFormat::formatDuration with a very large duration, and you pass an option (ex. ShowMilliseconds), the returned value is different than if it was without the option. Python example (same issue in C++ and QMl): from PyKF5 import KCoreAddons INT = 9999999999 mformat = KCoreAddons.KFormat() print("KFormat.ShowMilliseconds: {}".format(mformat.formatDuration(INT, KCoreAddons.KFormat.ShowMilliseconds))) print("No options: {}".format(mformat.formatDuration(INT))) >> KFormat.ShowMilliseconds: 2777:46:39.999 >> No options: 391:41:05