[libcamera-devel] [PATCH] qcam: fix Qt5.15.0 compile

Peter Seiderer ps.report at gmx.net
Mon Jun 8 23:11:02 CEST 2020


Hello Laurent,

On Mon, 8 Jun 2020 04:18:56 +0300, Laurent Pinchart <laurent.pinchart at ideasonboard.com> wrote:

> Hi Peter,
> 
> On Sun, Jun 07, 2020 at 11:58:26PM +0200, Peter Seiderer wrote:
> > On Sun, 7 Jun 2020 20:17:29 +0300, Laurent Pinchart <laurent.pinchart at ideasonboard.com> wrote:  
> > > On Sun, Jun 07, 2020 at 06:56:55PM +0200, Peter Seiderer wrote:  
> > > > Fixes:
> > > > 
> > > >   ../src/qcam/main_window.cpp:634:16: error: ‘QTextStream& QTextStreamFunctions::fixed(QTextStream&)’ is deprecated: Use Qt::fixed [-Werror=deprecated-declarations]
> > > >     634 |   << "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
> > > >         |                ^~~~~
> > > > Signed-off-by: Peter Seiderer <ps.report at gmx.net>
> > > > ---
> > > >  src/qcam/main_window.cpp | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> > > > index 7de0895..1f3bdc1 100644
> > > > --- a/src/qcam/main_window.cpp
> > > > +++ b/src/qcam/main_window.cpp
> > > > @@ -631,7 +631,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)
> > > >  		<< QString("seq: %1").arg(metadata.sequence, 6, 10, QLatin1Char('0'))
> > > >  		<< "bytesused:" << metadata.planes[0].bytesused
> > > >  		<< "timestamp:" << metadata.timestamp
> > > > -		<< "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
> > > > +		<< "fps:" << Qt::fixed << qSetRealNumberPrecision(2) << fps;    
> > > 
> > > Hasn't Qt::fixed been introduced in Qt v5.14, wouldn't this break
> > > compatibility with all older Qt versions ?  
> > 
> > Yes, you are right...
> >   
> > > One option I haven't tested would be to keep Qt::fixed here, and add, at
> > > the top of this file, something along those lines.
> > > 
> > > #if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
> > > /*
> > >  * Qt::fixed was introduced in v5.14, and ::fixed deprecated in v5.15. Allow
> > >  * usage of Qt::fixed unconditionally.
> > >  */
> > > namespace Qt {
> > > using fixed = ::fixed;
> > > } /* namespace Qt */
> > > #endif
> > > 
> > > Would you be able to test this ?  
> > 
> > Did try with Qt5.10.1 (with a standalone test program), leads to:
> > 
> >   test-qt-fixed.cpp:10:17: error: ‘fixed’ in namespace ‘::’ does not name a type
> >      10 | using fixed = ::fixed;
> >         |                 ^~~~~
> > 
> > 
> > Alternative would be:
> > 
> > [...]
> > #if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
> > 	<< fixed
> > #else
> > 	<< Qt::fixed
> > #endif
> > [...]  
> 
> That would require an #if for every usage of fixed, which isn't very
> nice (even if we use it in a single place only). I've tested the
> following v5.14 but can't easily test on older Qt versions. Could you
> test v5.10 ?

Yes, can do...

> 
> #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
> /*
>  * Qt::fixed was introduced in v5.14, and ::fixed deprecated in v5.15. Allow
>  * usage of Qt::fixed unconditionally.
>  */
> namespace Qt {
> constexpr auto fixed = ::fixed;
> } /* namespace Qt */
> #endif

This one works with Qt5.10.1...

Regards,
Peter

> 
> > Should I re-spin the patch?
> >   
> > > >  
> > > >  	/* Render the frame on the viewfinder. */
> > > >  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);    
> 



More information about the libcamera-devel mailing list