Skip to content

Commit 335d77e

Browse files
authored
Fix problems in Qt5.11 generator (#128)
- a previous fix for Qt5.12 breaks pythonqt_generator for 5.11 - includes better checking for precompiled headers and errors out early rather than failing when linking the src/ with mysterious missing symbols.
1 parent e9842d2 commit 335d77e

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

build/common.prf

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,50 +25,36 @@ PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp
2525
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_$${QT_MAJOR_VERSION}$${QT_MINOR_VERSION}
2626

2727
!exists($$PYTHONQT_GENERATED_PATH) {
28-
contains( QT_MAJOR_VERSION, 5 ) {
29-
contains( QT_MINOR_VERSION, 10 ) {
30-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
31-
}
32-
else:contains( QT_MINOR_VERSION, 11 ) {
33-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
34-
}
35-
else:contains( QT_MINOR_VERSION, 12 ) {
36-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
37-
}
38-
else:contains( QT_MINOR_VERSION, 1 ) {
39-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_50
40-
}
41-
else:contains( QT_MINOR_VERSION, 2 ) {
28+
# For Qt5 we know that the older generated wrappers work with the later
29+
# versions, even (apparently) Qt5.15, so:
30+
equals(QT_MAJOR_VERSION, 5) {
31+
# Qt5: have 5.0, 5.3, 5.4, 5.6 and 5.11 at present:
32+
lessThan(QT_MINOR_VERSION, 3) { # 5.1, 5.2
4233
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_50
4334
}
44-
else:contains( QT_MINOR_VERSION, 3 ) {
45-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_53
46-
}
47-
else:contains( QT_MINOR_VERSION, 4 ) {
35+
else: lessThan(QT_MINOR_VERSION, 6) { # 5.5
4836
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_54
49-
}
50-
else:contains( QT_MINOR_VERSION, 5 ) {
51-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_54
52-
}
53-
else:contains( QT_MINOR_VERSION, 6 ) {
54-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
5537
}
56-
else:contains( QT_MINOR_VERSION, 7 ) {
38+
else: lessThan(QT_MINOR_VERSION, 11) { # 5.7, 5.8, 5.9, 5.10
5739
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
5840
}
59-
else:contains( QT_MINOR_VERSION, 8 ) {
60-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
61-
}
62-
else:contains( QT_MINOR_VERSION, 9 ) {
63-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
64-
}
65-
else {
66-
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
41+
else { # >5.11
42+
# LATEST Qt5 generated files:
43+
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
6744
}
6845
}
46+
47+
!exists($$PYTHONQT_GENERATED_PATH) {
48+
error("No generated sources exist for Qt$${QT_VERSION}")
49+
}
6950
}
7051
}
7152

53+
!build_pass {
54+
message("Qt version: Qt$${QT_VERSION}")
55+
message("Using generated sources files from $${PYTHONQT_GENERATED_PATH}")
56+
}
57+
7258
VERSION = 3.2.0
7359
win32: CONFIG += skip_target_version_ext
7460
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -pedantic

generator/qtscript_masterinclude.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
** $QT_END_LICENSE$
3939
**
4040
****************************************************************************/
41-
4241
// We need to force the endianess in Qt5
4342
#define Q_BYTE_ORDER Q_LITTLE_ENDIAN
4443

@@ -48,11 +47,31 @@
4847
#define QOPENGLFUNCTIONS_H
4948
#define QOPENGLEXTRAFUNCTIONS_H
5049

51-
// our compiler can't handle the templates for singleShot (int Qt 5.12), but we can circumvent this with
52-
// Q_CLANG_QDOC for the moment:
53-
#define Q_CLANG_QDOC
54-
#include <QtCore/QTimer>
55-
#undef Q_CLANG_QDOC
50+
/* This must only be included after 'QT_NO_' definitions have been defined. */
51+
#include <QtCore/qglobal.h>
52+
53+
/* NOTE: Qt5.12 and later (including Qt6) uses template functions for the
54+
* static implementations of QTimer::singleShot() (the function, not the
55+
* property). The generator does not handle template functions. Defining
56+
* Q_CLANG_QDOC works around this by exposing the non-template forms that
57+
* appear in the documentation at the same time as hiding the templates.
58+
* Without this the QTimer::singleShot functions do not appear in the PythonQt
59+
* interface.
60+
*
61+
* Unfortunately the work around breaks precompilation in Qt5.11 because it
62+
* causes duplicate definitions of some text handling functions (they really
63+
* are duplicated if Q_CLANG_QDOC is turned on) so the change must be version
64+
* specific.
65+
*
66+
* This does not work in Qt6 because Qt6 uses Q_QDOC for the documentation and
67+
* needs other fixes.
68+
*/
69+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR > 11
70+
# include <QtCore/QObject> // included by QtCore/QTimer
71+
# define Q_CLANG_QDOC
72+
# include <QtCore/QTimer>
73+
# undef Q_CLANG_QDOC
74+
#endif
5675

5776
#include <QtCore/QtCore>
5877
#include <QtGui/QtGui>

0 commit comments

Comments
 (0)