[libcamera-devel] [PATCH] qcam: fix Qt5.15.0 compile
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Jun 9 12:20:56 CEST 2020
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 at 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 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...
>
> 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 at 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 at gmx.net>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham at 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]);
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list