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 <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2020-03-08 11:39:02 -07:00
parent 9caf4650c1
commit 839209d219
1 changed files with 10 additions and 10 deletions

View File

@ -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");
}