[PyQt] PyQt_qreal_double (Was: Re: PyQt5 5.7.1 Bug: debug build on Windows broken)
Phil Thompson
phil at riverbankcomputing.com
Fri Jan 20 15:41:49 GMT 2017
On 19 Jan 2017, at 11:47 am, Dmitry Shachnev <mitya57 at ubuntu.com> wrote:
>
> Hi all,
>
> On Tue, Jan 17, 2017 at 06:33:31PM +0100, Hans-Peter Jansen wrote:
>>> We now have this patch in Debian too (thanks Pete!).
>>
>> Hehe. Funnily, the fix_qreal_check.diff mentioned below in "openSUSE patches
>> of PyQt" is yours. Thank you, Dmitry. The world "feels" small sometimes.
>>
>> You might want to comment on this, why Phil should consider your approach.
>
> We no longer have this patch in Debian because we switched to qreal = double
> on all architectures, however having this patch applied to mainstream PyQt
> would still make sense in my opinion.
>
> While qreal = double by default, it is still possible (and supported) to do
> a custom Qt build with qreal = float. As far as I know, Sailfish still has
> qreal = float, so it would be useful at least for them.
>
> I would also update the patch because the sizeof-based check can be applied
> always, not only for old Qt versions.
>
> However there are some inconsistencies in PyQt code. It seems quite naturally
> that PyQt_qreal_double tells that qreal *is* double. The code in qglobal.sip
> seems to agree with that definition:
>
> %If (PyQt_qreal_double)
> typedef double qreal;
> %End
> %If (!PyQt_qreal_double)
> typedef float qreal;
> %End
>
> However, the code in (unpatched) configure.py and qpygui_qvector.sip seems to
> be using the opposite logic. Here is a fragment from qpygui_qvector.sip:
>
> %If (PyQt_qreal_double)
>
> %MappedType QVector<qreal>
> /TypeHintIn="Iterable[float]", TypeHintOut="List[float]",
> TypeHintValue="[]"/
>
> I hope Phil can clarify what is correct and what is not.
If you are referring to "float" in the above, it is the Python float not the C++ float.
> A potential updated patch for configure.py that would agree with qglobal.sip
> code is below (note the '==' instead of '!=' which was in the initial patch).
> When applying this, the code in qpygui_qvector.sip should be either fixed or
> dropped altogether.
>
> To test the changes with qreal = float, qtbase should be configured with
> '-qreal float' option.
I assume this sets the QT_COORD_TYPE preprocessor symbol. Is it supported to do '-qreal int'?
> --- a/configure.py
> +++ b/configure.py
> @@ -687,13 +687,8 @@ int main(int argc, char **argv)
> out << "PyQt_Desktop_OpenGL\\n";
> #endif
>
> -#if QT_VERSION < 0x050200
> -// This is the test used in qglobal.h in Qt prior to v5.2. In v5.2 and later
> -// qreal is always double.
> -#if defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE)
> - out << "PyQt_qreal_double\\n";
> -#endif
> -#endif
> + if (sizeof (qreal) == sizeof (double))
> + out << "PyQt_qreal_double\\n";
>
> #if defined(QT_NO_PROCESS)
> out << "PyQt_Process\\n";
The values being generated are to *disable* those features and not enable them. So your patch does exactly the opposite of what you intended.
Phil
More information about the PyQt
mailing list