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

Message ID 20200607165655.4844-1-ps.report@gmx.net
State Accepted
Delegated to: Laurent Pinchart
Headers show
Series
  • [libcamera-devel] qcam: fix Qt5.15.0 compile
Related show

Commit Message

Peter Seiderer June 7, 2020, 4:56 p.m. UTC
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@gmx.net>
---
 src/qcam/main_window.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart June 7, 2020, 5:17 p.m. UTC | #1
Hi Peter,

Thank you for the patch.

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@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 ?

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 ?

>  
>  	/* Render the frame on the viewfinder. */
>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);
Peter Seiderer June 7, 2020, 9:58 p.m. UTC | #2
Hello Laurent,

On Sun, 7 Jun 2020 20:17:29 +0300, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> Hi Peter,
> 
> Thank you for the patch.
> 
> 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@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
[...]

Should I re-spin the patch?

Regards,
Peter

> 
> >  
> >  	/* Render the frame on the viewfinder. */
> >  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);  
>
Laurent Pinchart June 8, 2020, 1:18 a.m. UTC | #3
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@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@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 ?

#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

> Should I re-spin the patch?
> 
> > >  
> > >  	/* Render the frame on the viewfinder. */
> > >  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);
Peter Seiderer June 8, 2020, 9:11 p.m. UTC | #4
Hello Laurent,

On Mon, 8 Jun 2020 04:18:56 +0300, Laurent Pinchart <laurent.pinchart@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@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@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]);    
>
Laurent Pinchart June 8, 2020, 9:32 p.m. UTC | #5
Hi Peter,

On Mon, Jun 08, 2020 at 11:11:02PM +0200, Peter Seiderer wrote:
> On Mon, 8 Jun 2020 04:18:56 +0300, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:
> > 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@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@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...

Great ! Thank you for testing.

Are you fine with the following patch ? If so there's no need to send a
new version.

commit 3dd6902e12c73cdcb5ef1a0ce0aceee5c9008306
Author: Peter Seiderer <ps.report@gmx.net>
Date:   Sun Jun 7 18:56:55 2020 +0200

    qcam: Fix compilation with Qt v5.15.0
    
    Starting from Qt v5.15.0, the QTextStreamFunctions::fixed function
    used to configure formatting on QTextStream is deprecated in favour of
    Qt::fixed. This causes a compilation error:
    
      ../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;
            |                ^~~~~
    
    Fix it by using Qt::fixed, and provide backward compatibility with Qt
    versions older than v5.14.0 that didn't provide Qt::fixed.
    
    Signed-off-by: Peter Seiderer <ps.report@gmx.net>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 7de089571234..2960259f4213 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -31,6 +31,16 @@
 
 using namespace libcamera;
 
+#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
+
 /**
  * \brief Custom QEvent to signal capture completion
  */
@@ -631,7 +641,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;
 
 	/* Render the frame on the viewfinder. */
 	viewfinder_->render(buffer, &mappedBuffers_[buffer]);


> >> Should I re-spin the patch?
> >>   
> >>>>  
> >>>>  	/* Render the frame on the viewfinder. */
> >>>>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);
Peter Seiderer June 8, 2020, 9:40 p.m. UTC | #6
Hello Laurent,

On Tue, 9 Jun 2020 00:32:32 +0300, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> Hi Peter,
> 
> On Mon, Jun 08, 2020 at 11:11:02PM +0200, Peter Seiderer wrote:
> > On Mon, 8 Jun 2020 04:18:56 +0300, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:  
> > > 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@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@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...  
> 
> Great ! Thank you for testing.
> 
> Are you fine with the following patch ? If so there's no need to send a
> new version.

Yes, fine for me...

Regards,
Peter
 
> 
> commit 3dd6902e12c73cdcb5ef1a0ce0aceee5c9008306
> Author: Peter Seiderer <ps.report@gmx.net>
> Date:   Sun Jun 7 18:56:55 2020 +0200
> 
>     qcam: Fix compilation with Qt v5.15.0
>     
>     Starting from Qt v5.15.0, the QTextStreamFunctions::fixed function
>     used to configure formatting on QTextStream is deprecated in favour of
>     Qt::fixed. This causes a compilation error:
>     
>       ../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;
>             |                ^~~~~
>     
>     Fix it by using Qt::fixed, and provide backward compatibility with Qt
>     versions older than v5.14.0 that didn't provide Qt::fixed.
>     
>     Signed-off-by: Peter Seiderer <ps.report@gmx.net>
>     Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 7de089571234..2960259f4213 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -31,6 +31,16 @@
>  
>  using namespace libcamera;
>  
> +#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
> +
>  /**
>   * \brief Custom QEvent to signal capture completion
>   */
> @@ -631,7 +641,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;
>  
>  	/* Render the frame on the viewfinder. */
>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);
> 
> 
> > >> Should I re-spin the patch?
> > >>     
> > >>>>  
> > >>>>  	/* Render the frame on the viewfinder. */
> > >>>>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);      
>
Kieran Bingham June 9, 2020, 10:20 a.m. UTC | #7
Hi Peter, Laurent,

On 08/06/2020 22:32, Laurent Pinchart wrote:
> Hi Peter,
> 
> On Mon, Jun 08, 2020 at 11:11:02PM +0200, Peter Seiderer wrote:
>> On Mon, 8 Jun 2020 04:18:56 +0300, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:
>>> 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@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@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...
> 
> Great ! Thank you for testing.
> 
> Are you fine with the following patch ? If so there's no need to send a
> new version.
> 
> commit 3dd6902e12c73cdcb5ef1a0ce0aceee5c9008306
> Author: Peter Seiderer <ps.report@gmx.net>
> Date:   Sun Jun 7 18:56:55 2020 +0200
> 
>     qcam: Fix compilation with Qt v5.15.0
>     
>     Starting from Qt v5.15.0, the QTextStreamFunctions::fixed function
>     used to configure formatting on QTextStream is deprecated in favour of
>     Qt::fixed. This causes a compilation error:
>     
>       ../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;
>             |                ^~~~~
>     
>     Fix it by using Qt::fixed, and provide backward compatibility with Qt
>     versions older than v5.14.0 that didn't provide Qt::fixed.
>     
>     Signed-off-by: Peter Seiderer <ps.report@gmx.net>
>     Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # 5.12.8


Run-time dependency qt5 (modules: Core, Gui, Widgets) found: YES 5.12.8
(pkg-config)
Detecting Qt5 tools
 moc: YES (/usr/lib/x86_64-linux-gnu/qt5/bin/moc, 5.12.8)
 uic: YES (/usr/lib/x86_64-linux-gnu/qt5/bin/uic, 5.12.8)
 rcc: YES (/usr/lib/x86_64-linux-gnu/qt5/bin/rcc, 5.12.8)
 lrelease: YES (/usr/lib/x86_64-linux-gnu/qt5/bin/lrelease, 5.12.8)

--
Kieran


> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 7de089571234..2960259f4213 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -31,6 +31,16 @@
>  
>  using namespace libcamera;
>  
> +#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
> +
>  /**
>   * \brief Custom QEvent to signal capture completion
>   */
> @@ -631,7 +641,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;
>  
>  	/* Render the frame on the viewfinder. */
>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);
> 
> 
>>>> Should I re-spin the patch?
>>>>   
>>>>>>  
>>>>>>  	/* Render the frame on the viewfinder. */
>>>>>>  	viewfinder_->render(buffer, &mappedBuffers_[buffer]);    
>

Patch

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;
 
 	/* Render the frame on the viewfinder. */
 	viewfinder_->render(buffer, &mappedBuffers_[buffer]);