From 839209d2198cc06ca768dcb5e428ca6b21974b25 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 8 Mar 2020 11:39:02 -0700 Subject: [PATCH] Fix formatting of the start time and elapsed time. There's no QString arg(uint a, int fieldWidth = 0, QChar fillChar = QLatin1Char(' ')) const version of the arg method of QString, there's only QString arg(uint a, int fieldWidth = 0, int base = 10, QChar fillChar = Latin1Char(' ')) const so if you don't pass the base argument, it turns the QChar into an int (presumably using the unicode method, so that ends up being 0x20 or 32), passes it as the base argument (so it does the conversion base-32 - that's <= 36, so it's a valid value for the base argument), and defaults the fillChar argument to space. Add 10 as the base argument, so it behaves correctly. Bug: 16429 Change-Id: If4872d6d55aa5d9a7489219622d4190827e65d34 Reviewed-on: https://code.wireshark.org/review/36337 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- ui/qt/capture_file_dialog.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index 51a7a6dc36..edb43a6ee0 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -923,12 +923,12 @@ void CaptureFileDialog::preview(const QString & path) first_elapsed = "?"; if (ti_tm) { first_elapsed = QString("%1-%2-%3 %4:%5:%6") - .arg(ti_tm->tm_year + 1900, 4, QChar('0')) - .arg(ti_tm->tm_mon + 1, 2, QChar('0')) - .arg(ti_tm->tm_mday, 2, QChar('0')) - .arg(ti_tm->tm_hour, 2, QChar('0')) - .arg(ti_tm->tm_min, 2, QChar('0')) - .arg(ti_tm->tm_sec, 2, QChar('0')); + .arg(ti_tm->tm_year + 1900, 4, 10, QChar('0')) + .arg(ti_tm->tm_mon + 1, 2, 10, QChar('0')) + .arg(ti_tm->tm_mday, 2, 10, QChar('0')) + .arg(ti_tm->tm_hour, 2, 10, QChar('0')) + .arg(ti_tm->tm_min, 2, 10, QChar('0')) + .arg(ti_tm->tm_sec, 2, 10, QChar('0')); } } else { first_elapsed = tr("unknown"); @@ -947,13 +947,13 @@ void CaptureFileDialog::preview(const QString & path) // elapsed_time = (unsigned int)(stats.stop_time-stats.start_time); if (elapsed_time/86400) { - first_elapsed += QString("%1 days ").arg(elapsed_time/86400, 2, QChar('0')); + first_elapsed += QString("%1 days ").arg(elapsed_time/86400, 2, 10, QChar('0')); elapsed_time = elapsed_time % 86400; } first_elapsed += QString("%2:%3:%4") - .arg(elapsed_time%86400/3600, 2, QChar('0')) - .arg(elapsed_time%3600/60, 2, QChar('0')) - .arg(elapsed_time%60, 2, QChar('0')); + .arg(elapsed_time%86400/3600, 2, 10, QChar('0')) + .arg(elapsed_time%3600/60, 2, 10, QChar('0')) + .arg(elapsed_time%60, 2, 10, QChar('0')); } else { first_elapsed += tr("unknown"); }