Message ID | 20200429193156.28041-1-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Commit | bf01e04f29931aa6d64f3d408ce2a374b79254b6 |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your work. On 2020-04-29 22:31:56 +0300, Laurent Pinchart wrote: > The sequence number of captured frames is logged to the console with > padding to 6 characters to increase readability. The output is however > incorrect, as 123 is printed as 00012300000. This is caused by the > auto-space feature of QDebug, which inserts a space after every field. > This doesn't play well with stream format manipulation, as it ends up > padding the automatically inserted space the same way as the previous > argument. > > This is a bug in Qt, work around it by formatting the sequence number > manually. > > Fixes: 494da4467ddf ("qcam: Use Qt qInfo() and qWarning() logging facilities") > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/qcam/main_window.cpp | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp > index ed0cad417d62..d021fa9552de 100644 > --- a/src/qcam/main_window.cpp > +++ b/src/qcam/main_window.cpp > @@ -531,8 +531,8 @@ void MainWindow::processCapture() > fps = lastBufferTime_ && fps ? 1000000000.0 / fps : 0.0; > lastBufferTime_ = metadata.timestamp; > > - qInfo() << "seq:" << qSetFieldWidth(6) << qSetPadChar('0') > - << metadata.sequence << reset > + qInfo().noquote() > + << QString("seq: %1").arg(metadata.sequence, 6, 10, QLatin1Char('0')) > << "bytesused:" << metadata.planes[0].bytesused > << "timestamp:" << metadata.timestamp > << "fps:" << fixed << qSetRealNumberPrecision(2) << fps; > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index ed0cad417d62..d021fa9552de 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -531,8 +531,8 @@ void MainWindow::processCapture() fps = lastBufferTime_ && fps ? 1000000000.0 / fps : 0.0; lastBufferTime_ = metadata.timestamp; - qInfo() << "seq:" << qSetFieldWidth(6) << qSetPadChar('0') - << metadata.sequence << reset + qInfo().noquote() + << QString("seq: %1").arg(metadata.sequence, 6, 10, QLatin1Char('0')) << "bytesused:" << metadata.planes[0].bytesused << "timestamp:" << metadata.timestamp << "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
The sequence number of captured frames is logged to the console with padding to 6 characters to increase readability. The output is however incorrect, as 123 is printed as 00012300000. This is caused by the auto-space feature of QDebug, which inserts a space after every field. This doesn't play well with stream format manipulation, as it ends up padding the automatically inserted space the same way as the previous argument. This is a bug in Qt, work around it by formatting the sequence number manually. Fixes: 494da4467ddf ("qcam: Use Qt qInfo() and qWarning() logging facilities") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/qcam/main_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)