Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 Compatibilty #111

Merged
merged 21 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
77e3883
Qt6 compatibility fixes for core PythonQt library
richard42 Aug 21, 2023
10d4048
Bring back more Qt5 compatibility
mrbean-bremen Sep 15, 2023
6d74c14
More Qt5 compatibility changes
mrbean-bremen Sep 15, 2023
c40e134
Bring back QRegExp and QMatrix for Qt5
mrbean-bremen Sep 19, 2023
3c05268
Qt6: initial changes to make compilation work (#114)
jbowler Oct 3, 2023
02e4c94
Replace deprecated QAtomicPointer<T>::load() (#115)
jbowler Oct 3, 2023
3db7846
Qt6: QList<T>operator== requires const T::operator== (#116)
jbowler Oct 3, 2023
bb3d8e6
Qt6: qSort and qStableSort removed (#117)
jbowler Oct 4, 2023
bf0b53c
Qt6: qSort, toList and fromList removal (#118)
jbowler Oct 5, 2023
d87d01c
Qt6: QString::SkipEmptyParts moved to Qt (#119)
jbowler Oct 5, 2023
319a4a7
Qt6: QTextStream compatibility (#120)
jbowler Oct 5, 2023
8736b53
Eliminate warnings about #warning (#122)
jbowler Oct 9, 2023
5df5cbb
Qt6: generator/typesystem.cpp: XML workround (#123)
jbowler Oct 9, 2023
85dee26
Add constexpr and decltype parsing (#125)
jbowler Oct 11, 2023
b7d72e0
Handle constexpr, auto (#126)
jbowler Oct 12, 2023
9b45889
Qt6: fixes for removal of Qt5 types (#127)
jbowler Oct 13, 2023
2f657db
Fix problems in Qt5.11 generator (#128)
jbowler Oct 14, 2023
9404b9a
Use spaces instead of tabs (#129)
jbowler Oct 14, 2023
b39d565
generator: remove anonymous structs (#121)
jbowler Oct 15, 2023
25f8485
generator: call Reporthandler::setContext more (#131)
jbowler Oct 16, 2023
38979b7
generator: AbstractMetaClassList: correct sorting (#132)
jbowler Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set expandtab
12 changes: 6 additions & 6 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Expand All @@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]

Preamble
Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Expand Down Expand Up @@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License Agreement applies to any software library or other
Expand Down Expand Up @@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.

NO WARRANTY
NO WARRANTY

15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
Expand All @@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Libraries

Expand Down
55 changes: 20 additions & 35 deletions build/common.prf
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,39 @@ PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_$${QT_MAJOR_VERSION}$${QT_MINOR_VERSION}

!exists($$PYTHONQT_GENERATED_PATH) {
contains( QT_MAJOR_VERSION, 5 ) {
contains( QT_MINOR_VERSION, 10 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else:contains( QT_MINOR_VERSION, 11 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
}
else:contains( QT_MINOR_VERSION, 12 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
}
else:contains( QT_MINOR_VERSION, 1 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_50
}
else:contains( QT_MINOR_VERSION, 2 ) {
# For Qt5 we know that the older generated wrappers work with the later
# versions, even (apparently) Qt5.15, so:
equals(QT_MAJOR_VERSION, 5) {
# Qt5: have 5.0, 5.3, 5.4, 5.6 and 5.11 at present:
lessThan(QT_MINOR_VERSION, 3) { # 5.1, 5.2
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_50
}
else:contains( QT_MINOR_VERSION, 3 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_53
}
else:contains( QT_MINOR_VERSION, 4 ) {
else: lessThan(QT_MINOR_VERSION, 6) { # 5.5
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_54
}
else:contains( QT_MINOR_VERSION, 5 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_54
}
else:contains( QT_MINOR_VERSION, 6 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else:contains( QT_MINOR_VERSION, 7 ) {
else: lessThan(QT_MINOR_VERSION, 11) { # 5.7, 5.8, 5.9, 5.10
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else:contains( QT_MINOR_VERSION, 8 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else:contains( QT_MINOR_VERSION, 9 ) {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
}
else {
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_56
else { # >5.11
# LATEST Qt5 generated files:
PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp_511
}
}

!exists($$PYTHONQT_GENERATED_PATH) {
error("No generated sources exist for Qt$${QT_VERSION}")
}
}
}

!build_pass {
message("Qt version: Qt$${QT_VERSION}")
message("Using generated sources files from $${PYTHONQT_GENERATED_PATH}")
}

VERSION = 3.2.0
greaterThan(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 9): CONFIG += c++11
win32: CONFIG += skip_target_version_ext
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -ansi -pedantic
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -pedantic
win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-unused-command-line-argument
#Do not issue warning to system includes
gcc:!isEmpty(QT_INSTALL_HEADERS): QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS]
4 changes: 1 addition & 3 deletions examples/CPPPyWrapperExample/CPPPyWrapperExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ DESTDIR = ../../lib
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

SOURCES += \
CPPPyWrapperExample.cpp
Expand Down
4 changes: 1 addition & 3 deletions examples/PyCPPWrapperExample/PyCPPWrapperExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ DESTDIR = ../../lib
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

HEADERS += \
CustomObjects.h
Expand Down
4 changes: 1 addition & 3 deletions examples/PyCustomMetaTypeExample/PyCustomMetaTypeExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ DESTDIR = ../../lib
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

HEADERS += \
CustomObject.h
Expand Down
4 changes: 1 addition & 3 deletions examples/PyDecoratorsExample/PyDecoratorsExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ DESTDIR = ../../lib
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

HEADERS += \
PyExampleDecorators.h
Expand Down
4 changes: 1 addition & 3 deletions examples/PyGettingStarted/PyGettingStarted.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ CONFIG += console
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

SOURCES += \
main.cpp
Expand Down
4 changes: 1 addition & 3 deletions examples/PyGuiExample/PyGuiExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ mac:CONFIG -= app_bundle

DESTDIR = ../../lib

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
Expand Down
4 changes: 1 addition & 3 deletions examples/PyLauncher/PyLauncher.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ mac:CONFIG -= app_bundle

DESTDIR = ../../lib

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
Expand Down
4 changes: 1 addition & 3 deletions examples/PyScriptingConsole/PyScriptingConsole.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
include ( ../../build/PythonQt_QtAll.prf )

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
}
QT += widgets

HEADERS += \
PyExampleObject.h
Expand Down
14 changes: 7 additions & 7 deletions generator/LICENSE.LGPL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE

The Qt GUI Toolkit is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
Contact: Nokia Corporation ([email protected])
Expand All @@ -8,8 +8,8 @@

-------------------------------------------------------------------------

GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Expand All @@ -20,7 +20,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]

Preamble
Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Expand Down Expand Up @@ -122,7 +122,7 @@ modification follow. Pay close attention to the difference between a
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License Agreement applies to any software library or other
Expand Down Expand Up @@ -442,7 +442,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.

NO WARRANTY
NO WARRANTY

15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
Expand All @@ -465,7 +465,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Libraries

Expand Down
46 changes: 34 additions & 12 deletions generator/abstractmetabuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTextCodec>
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
# include <QtCore/QTextCodec>
#endif
#include <QtCore/QTextStream>
#include <QtCore/QVariant>

Expand Down Expand Up @@ -376,15 +378,9 @@ void AbstractMetaBuilder::fixQObjectForScope(TypeDatabase *types,
}
}

static bool class_less_than(AbstractMetaClass *a, AbstractMetaClass *b)
{
return a->name() < b->name();
}


void AbstractMetaBuilder::sortLists()
{
qSort(m_meta_classes.begin(), m_meta_classes.end(), class_less_than);
m_meta_classes.sort();
for (AbstractMetaClass *cls : m_meta_classes) {
cls->sortFunctions();
}
Expand All @@ -400,7 +396,10 @@ bool AbstractMetaBuilder::build()
return false;

QTextStream stream(&file);
stream.setCodec(QTextCodec::codecForName("UTF-8"));
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
stream.setCodec(QTextCodec::codecForName("UTF-8"));
/* Note required in Qt6: see the same call in asttoxml.cpp */
# endif
QByteArray contents = stream.readAll().toUtf8();
file.close();

Expand Down Expand Up @@ -971,7 +970,7 @@ AbstractMetaEnum *AbstractMetaBuilder::traverseEnum(EnumModelItem enum_item, Abs
meta_enum->addEnumValue(meta_enum_value);

ReportHandler::debugFull(" - " + meta_enum_value->name() + " = "
+ meta_enum_value->value());
+ QString::number(meta_enum_value->value()));

// Add into global register...
if (enclosing)
Expand Down Expand Up @@ -1444,7 +1443,13 @@ void AbstractMetaBuilder::traverseEnums(ScopeModelItem scope_item, AbstractMetaC
{
EnumList enums = scope_item->enums();
for (EnumModelItem enum_item : enums) {
AbstractMetaEnum *meta_enum = traverseEnum(enum_item, meta_class, QSet<QString>::fromList(enumsDeclarations));
AbstractMetaEnum *meta_enum = traverseEnum(enum_item, meta_class,
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
QSet<QString>::fromList(enumsDeclarations)
#else
QSet<QString>(enumsDeclarations.begin(), enumsDeclarations.end())
#endif
);
if (meta_enum) {
meta_enum->setOriginalAttributes(meta_enum->attributes());
meta_class->addEnum(meta_enum);
Expand Down Expand Up @@ -1476,6 +1481,19 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
return 0;
}

if (function_item->isAuto()) {
/*TODO: it might work just to output 'auto', but this would require
* understanding what AbstractMetabuild::translateType() does and
* changing it. auto is only used once anyway.
*/
ReportHandler::warning(QString("%1: skipping auto function type '%2'")
.arg(function_name)
.arg(function_item->type().toString()));
m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] =
UnmatchedReturnType;
return 0;
}

QString cast_type;

if (function_name.startsWith("operator")) {
Expand All @@ -1491,6 +1509,8 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu

AbstractMetaFunction *meta_function = createMetaFunction();
meta_function->setConstant(function_item->isConstant());
meta_function->setConstexpr(function_item->isConstexpr());
meta_function->setAuto(function_item->isAuto());
meta_function->setException(function_item->exception());

ReportHandler::debugMedium(QString(" - %2()").arg(function_name));
Expand Down Expand Up @@ -1694,10 +1714,12 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
//newInfo.setArguments(typei.arguments());
newInfo.setIndirections(typei.indirections());
newInfo.setConstant(typei.isConstant());
newInfo.setConstexpr(typei.isConstexpr());
newInfo.setFunctionPointer(typei.isFunctionPointer());
newInfo.setQualifiedName(typei.qualifiedName());
newInfo.setReference(typei.isReference());
newInfo.setVolatile(typei.isVolatile());
newInfo.setMutable(typei.isMutable());

AbstractMetaType *elementType = translateType(newInfo, ok);
if (!(*ok))
Expand Down Expand Up @@ -2461,7 +2483,7 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted() const
AbstractMetaClassList res;

AbstractMetaClassList classes = m_meta_classes;
qSort(classes);
classes.sort();

QSet<AbstractMetaClass*> noDependency;
QHash<AbstractMetaClass*, QSet<AbstractMetaClass* >* > hash;
Expand Down
2 changes: 1 addition & 1 deletion generator/abstractmetabuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AbstractMetaBuilder
bool isEnum(const QStringList &qualified_name);

void fixQObjectForScope (TypeDatabase *types,
NamespaceModelItem item);
NamespaceModelItem item);

// QtScript
QSet<QString> qtMetaTypeDeclaredTypeNames() const
Expand Down
Loading
Loading