diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-19 11:45:49 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-19 11:46:14 +0100 |
commit | 1a15c93a220e07c12870d0cdff2eae1aff8eaeaf (patch) | |
tree | 5a847dc2eedec1201abc3f3dbede4b6590b31b55 /sources | |
parent | 04af851b4b886675fc68e0f8e637d9e399d4000c (diff) | |
parent | d3b003f4f63a82f4cca6f4f14cd3ebb2095b1ce8 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I0bebba45aa05c2eb02c35bf76b63bb7eaa67b562
Diffstat (limited to 'sources')
50 files changed, 366 insertions, 614 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index 6a8c612f3..bfd8eb5be 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -227,6 +227,9 @@ macro(COLLECT_MODULE_IF_FOUND shortname) set(name "Qt5${shortname}") find_package(${name}) set(_name_found "${name}_FOUND") + set(_name_dir "${name}_DIR") + get_filename_component(_qt_dir ${QT_INCLUDE_DIR} DIRECTORY) + get_filename_component(_module_dir "${${_name_dir}}/../../../" ABSOLUTE) # Determine essential/optional/missing set(module_state "missing") @@ -240,7 +243,7 @@ macro(COLLECT_MODULE_IF_FOUND shortname) set(module_state "essential") endif() - if(${_name_found}) + if(${${_name_found}} AND ${_qt_dir} STREQUAL ${_module_dir}) message(STATUS "${module_state} module ${name} found (${ARGN})") # record the shortnames for the tests list(APPEND all_module_shortnames ${shortname}) diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index 88d262ab7..fc2fc3013 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -216,17 +216,6 @@ <include file-name="signalmanager.h" location="global"/> </primitive-type> - <!-- Among other use cases, these types are necessary for OpenGL "GLint"-like typedefs on macOS. - --> - <primitive-type name="int64_t" /> - <primitive-type name="int32_t" /> - <primitive-type name="int16_t" /> - <primitive-type name="int8_t" /> - <primitive-type name="uint64_t" /> - <primitive-type name="uint32_t" /> - <primitive-type name="uint16_t" /> - <primitive-type name="uint8_t" /> - <primitive-type name="bool" target-lang-api-name="PyBool"> <conversion-rule> <native-to-target> @@ -2922,7 +2911,7 @@ QByteArray ba; ba.resize(%2); %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); - %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + %PYARG_0 = Shiboken::String::fromCString(ba.constData()); </inject-code> <modify-argument index="1"> <remove-argument /> @@ -2946,7 +2935,7 @@ QByteArray ba; ba.resize(%2); %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); - %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + %PYARG_0 = Shiboken::String::fromCString(ba.constData()); </inject-code> <modify-argument index="1"> <remove-argument /> @@ -2954,12 +2943,13 @@ <modify-argument index="return"> <replace-type modified-type="PyObject"/> <conversion-rule class="native"> - %RETURN_TYPE %out; - if (!PyBytes_Check(%PYARG_0)) { - %out = -1; - } else { + %RETURN_TYPE %out = 0; + if (PyBytes_Check(%PYARG_0)) { %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } else if (Shiboken::String::check(%PYARG_0)) { + %out = Shiboken::String::len((PyObject*)%PYARG_0); + memcpy(%1, Shiboken::String::toCString((PyObject*)%PYARG_0), %out); } </conversion-rule> </modify-argument> diff --git a/sources/pyside2/PySide2/QtHelp/CMakeLists.txt b/sources/pyside2/PySide2/QtHelp/CMakeLists.txt index 6e3334a80..342863a4f 100644 --- a/sources/pyside2/PySide2/QtHelp/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtHelp/CMakeLists.txt @@ -11,6 +11,7 @@ ${QtHelp_GEN_DIR}/qhelpindexwidget_wrapper.cpp ${QtHelp_GEN_DIR}/qhelpsearchengine_wrapper.cpp ${QtHelp_GEN_DIR}/qhelpsearchquerywidget_wrapper.cpp ${QtHelp_GEN_DIR}/qhelpsearchquery_wrapper.cpp +${QtHelp_GEN_DIR}/qhelpsearchresult_wrapper.cpp ${QtHelp_GEN_DIR}/qhelpsearchresultwidget_wrapper.cpp # module is always needed ${QtHelp_GEN_DIR}/qthelp_module_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtHelp/typesystem_help.xml b/sources/pyside2/PySide2/QtHelp/typesystem_help.xml index 7668cf8ad..6bd5dd364 100644 --- a/sources/pyside2/PySide2/QtHelp/typesystem_help.xml +++ b/sources/pyside2/PySide2/QtHelp/typesystem_help.xml @@ -61,5 +61,6 @@ <enum-type name="FieldName"/> </value-type> <object-type name="QHelpSearchQueryWidget"/> + <object-type name="QHelpSearchResult"/> <object-type name="QHelpSearchResultWidget"/> </typesystem> diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml index 945f8ebe0..0f8d8da4e 100644 --- a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml +++ b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml @@ -45,7 +45,7 @@ <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/> <load-typesystem name="QtWebKit/typesystem_webkit.xml" generate="no"/> <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/> - <load-typesystem name="typesystem_printsupport.xml" generate="no"/> + <load-typesystem name="QtPrintSupport/typesystem_printsupport.xml" generate="no"/> <value-type name="QWebDatabase"/> diff --git a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt index a1bcdb023..27dff2912 100644 --- a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt @@ -23,6 +23,7 @@ ${QtWidgets_GEN_DIR}/qbuttongroup_wrapper.cpp ${QtWidgets_GEN_DIR}/qcalendarwidget_wrapper.cpp ${QtWidgets_GEN_DIR}/qcheckbox_wrapper.cpp ${QtWidgets_GEN_DIR}/qcolordialog_wrapper.cpp +${QtWidgets_GEN_DIR}/qcolormap_wrapper.cpp ${QtWidgets_GEN_DIR}/qcolumnview_wrapper.cpp ${QtWidgets_GEN_DIR}/qcombobox_wrapper.cpp ${QtWidgets_GEN_DIR}/qcommandlinkbutton_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index d42547cd1..2c380dacb 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -190,6 +190,9 @@ <enum-type name="ViewItemPosition"/> </value-type> + <value-type name="QColormap"> + <enum-type name="Mode"/> + </value-type> <value-type name="QSizePolicy"> <enum-type name="ControlType" flags="ControlTypes"/> <enum-type name="Policy"/> @@ -2402,7 +2405,7 @@ </modify-argument> </modify-function> </object-type> - + <object-type name="QMessageBox"> <enum-type name="ButtonRole"/> <enum-type name="Icon"/> @@ -2605,7 +2608,7 @@ <insert-template name="return_for_QFileDialog"/> </inject-code> </modify-function> - + <modify-function signature="getOpenFileUrl(QWidget*, const QString&, const QUrl&, const QString&, QString*, QFlags<QFileDialog::Option>, const QStringList&)" allow-thread="yes"> <modify-argument index="return"> <replace-type modified-type="(fileName, selectedFilter)"/> diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake index 9c39980cb..83d43976a 100644 --- a/sources/pyside2/cmake/Macros/PySideModules.cmake +++ b/sources/pyside2/cmake/Macros/PySideModules.cmake @@ -71,8 +71,6 @@ macro(create_pyside_module set(shiboken_framework_include_dirs_option "") if(CMAKE_HOST_APPLE) set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}") - # On macOS, provide the framework paths for OpenGL headers. - set(shiboken_framework_include_dirs ${shiboken_framework_include_dirs} ${CMAKE_SYSTEM_FRAMEWORK_PATH}) make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs}) set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}") endif() @@ -121,7 +119,19 @@ macro(create_pyside_module install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module_name}/pyside2_${lower_module_name}_python.h DESTINATION include/PySide2${pyside2_SUFFIX}/${module_name}/) file(GLOB typesystem_files ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_*.xml ${typesystem_path}) - install(FILES ${typesystem_files} DESTINATION share/PySide2${pyside2_SUFFIX}/typesystems) + +# Copy typesystem files and remove module names from the <load-typesystem> element +# so that it works in a flat directory: +# <load-typesystem name="QtWidgets/typesystem_widgets.xml" ... -> +# <load-typesystem name="typesystem_widgets.xml" + foreach(typesystem_file ${typesystem_files}) + get_filename_component(typesystem_file_name "${typesystem_file}" NAME) + file(READ "${typesystem_file}" typesystemXml) + string(REGEX REPLACE "<load-typesystem name=\"[^/\"]+/" "<load-typesystem name=\"" typesystemXml "${typesystemXml}") + set (typesystem_target_file "${CMAKE_CURRENT_BINARY_DIR}/PySide2/typesystems/${typesystem_file_name}") + file(WRITE "${typesystem_target_file}" "${typesystemXml}") + install(FILES "${typesystem_target_file}" DESTINATION share/PySide2${pyside2_SUFFIX}/typesystems) + endforeach() endmacro() #macro(check_qt_class_with_namespace module namespace class optional_source_files dropped_entries [namespace] [module]) diff --git a/sources/pyside2/header.BSD b/sources/pyside2/header.BSD deleted file mode 100644 index aa400a469..000000000 --- a/sources/pyside2/header.BSD +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.COMM b/sources/pyside2/header.COMM deleted file mode 100644 index 1c8cb00e7..000000000 --- a/sources/pyside2/header.COMM +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the <Fill> module. -** -** $QT_BEGIN_LICENSE:COMM$ -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** $QT_END_LICENSE$ -** -******************************************************************************/ diff --git a/sources/pyside2/header.FDL b/sources/pyside2/header.FDL deleted file mode 100644 index 90195db13..000000000 --- a/sources/pyside2/header.FDL +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.GPL b/sources/pyside2/header.GPL deleted file mode 100644 index af4a1636b..000000000 --- a/sources/pyside2/header.GPL +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.GPL-EXCEPT b/sources/pyside2/header.GPL-EXCEPT deleted file mode 100644 index 26ed5a245..000000000 --- a/sources/pyside2/header.GPL-EXCEPT +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.LGPL-NOGPL2 b/sources/pyside2/header.LGPL-NOGPL2 deleted file mode 100644 index 80b4449cb..000000000 --- a/sources/pyside2/header.LGPL-NOGPL2 +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL-NOGPL2$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.LGPL-ONLY b/sources/pyside2/header.LGPL-ONLY deleted file mode 100644 index 9a676032e..000000000 --- a/sources/pyside2/header.LGPL-ONLY +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt.io/contact-us/. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ diff --git a/sources/pyside2/header.LGPL21 b/sources/pyside2/header.LGPL21 deleted file mode 100644 index 533390b07..000000000 --- a/sources/pyside2/header.LGPL21 +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.LGPL3 b/sources/pyside2/header.LGPL3 deleted file mode 100644 index d9a65c2e4..000000000 --- a/sources/pyside2/header.LGPL3 +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/header.LGPL3-COMM b/sources/pyside2/header.LGPL3-COMM deleted file mode 100644 index b5dc15d38..000000000 --- a/sources/pyside2/header.LGPL3-COMM +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3-COMM$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt index 4a0f27933..3a08cb45b 100644 --- a/sources/pyside2/tests/QtCore/CMakeLists.txt +++ b/sources/pyside2/tests/QtCore/CMakeLists.txt @@ -61,6 +61,7 @@ PYSIDE_TEST(qenum_test.py) PYSIDE_TEST(qevent_test.py) PYSIDE_TEST(qfileinfo_test.py) PYSIDE_TEST(qfile_test.py) +PYSIDE_TEST(qfileread_test.py) PYSIDE_TEST(qflags_test.py) PYSIDE_TEST(qinstallmsghandler_test.py) PYSIDE_TEST(qlinef_test.py) diff --git a/sources/pyside2/tests/QtCore/qfileread_test.py b/sources/pyside2/tests/QtCore/qfileread_test.py new file mode 100644 index 000000000..3912fe7e6 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qfileread_test.py @@ -0,0 +1,82 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import unittest + +import os + +from PySide2.QtCore import QIODevice, QTemporaryFile + +class FileChild1(QTemporaryFile): + pass + +class FileChild2(QTemporaryFile): + def readData(self, maxlen): + return super(FileChild2, self).readData(maxlen) + def readLineData(self, maxlen): + return super(FileChild2, self).readLineData(maxlen) + +class readDataTest(unittest.TestCase): + '''Test case for readData and readLineData''' + + def setUp(self): + '''Acquire resources''' + self.filename1 = FileChild1() + self.assertTrue(self.filename1.open()) + self.filename1.write('Test text for testing') + + self.filename2 = FileChild2() + self.assertTrue(self.filename2.open()) + self.filename2.write('Test text for testing') + + def tearDown(self): + '''release resources''' + pass + + def testBasic(self): + '''QTemporaryFile.read''' + self.filename1.seek(0) + s1 = self.filename1.read(50) + self.assertEqual(s1, 'Test text for testing') + + + def testBug40(self): + self.filename2.seek(0) + s2 = self.filename2.read(50) + self.assertEqual(s2, 'Test text for testing') + + self.filename2.seek(0) + s2 = self.filename2.readLine(22) + self.assertEqual(s2, 'Test text for testing') + + self.filename1.seek(0) + s1 = self.filename1.read(50) + self.assertEqual(s1, s2) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py b/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py index d8f7bb3a5..08580823e 100644 --- a/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py +++ b/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py @@ -65,9 +65,10 @@ class QInstallMsgHandlerTest(unittest.TestCase): def testHandler(self): rethandler = qInstallMessageHandler(handler) - qDebug("Test Debug") - self.assertEqual(param[0], QtDebugMsg) - self.assertEqual(param[2], "Test Debug") + if QLibraryInfo.isDebugBuild(): + qDebug("Test Debug") + self.assertEqual(param[0], QtDebugMsg) + self.assertEqual(param[2], "Test Debug") qWarning("Test Warning") self.assertEqual(param[0], QtWarningMsg) self.assertEqual(param[2], "Test Warning") diff --git a/sources/pyside2/tests/QtHelp/CMakeLists.txt b/sources/pyside2/tests/QtHelp/CMakeLists.txt index d0ba2d80c..422dc51c7 100644 --- a/sources/pyside2/tests/QtHelp/CMakeLists.txt +++ b/sources/pyside2/tests/QtHelp/CMakeLists.txt @@ -1 +1,2 @@ PYSIDE_TEST(help_test.py) +PYSIDE_TEST(helpsearchengine_test.py) diff --git a/sources/pyside2/tests/QtHelp/helpsearchengine_test.py b/sources/pyside2/tests/QtHelp/helpsearchengine_test.py new file mode 100644 index 000000000..6bc4b684a --- /dev/null +++ b/sources/pyside2/tests/QtHelp/helpsearchengine_test.py @@ -0,0 +1,44 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import unittest + +from PySide2.QtHelp import QHelpEngineCore, QHelpSearchEngine, QHelpSearchResult + +from helper import UsesQApplication + +class QHelpSearchEngineTest(UsesQApplication): + + def testQHelpSearchEngine(self): + helpEngineCore = QHelpEngineCore('') + helpSearchEngine = QHelpSearchEngine(helpEngineCore) + helpSearchResult = helpSearchEngine.searchResults(0, 0) + self.assertEqual(len(helpSearchResult), 0) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index 3c31b1d7d..60a1d7d6f 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -125,6 +125,7 @@ PYSIDE_TEST(qvalidator_test.py) PYSIDE_TEST(qvariant_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) PYSIDE_TEST(qwidget_test.py) +PYSIDE_TEST(qcolormap_test.py) PYSIDE_TEST(reference_count_test.py) PYSIDE_TEST(returnquadruplesofnumbers_test.py) PYSIDE_TEST(standardpixmap_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qcolormap_test.py b/sources/pyside2/tests/QtWidgets/qcolormap_test.py new file mode 100644 index 000000000..c71216592 --- /dev/null +++ b/sources/pyside2/tests/QtWidgets/qcolormap_test.py @@ -0,0 +1,43 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import unittest + +from PySide2.QtWidgets import QColormap +from helper import UsesQApplication + + +class QColormapTest(UsesQApplication): + + def testQColormap(self): + qc = QColormap.instance() + self.assertEqual(qc.size(), -1) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 79d69abf3..38000785f 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -487,7 +487,7 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) const QSet<NamespaceModelItem> &namespaceTypeValues = dom->uniqueNamespaces(); ReportHandler::setProgressReference(namespaceTypeValues); - for (NamespaceModelItem item : namespaceTypeValues) { + for (const NamespaceModelItem &item : namespaceTypeValues) { ReportHandler::progress(QLatin1String("Generating namespace model...")); AbstractMetaClass *metaClass = traverseNamespace(dom, item); if (metaClass) @@ -1044,7 +1044,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(EnumModelItem enumIte TypeEntry* typeEntry = 0; if (enumItem->accessPolicy() == CodeModel::Private) { QStringList names = enumItem->qualifiedName(); - QString enumName = names.last(); + QString enumName = names.constLast(); QString nspace; if (names.size() > 1) nspace = QStringList(names.mid(0, names.size() - 1)).join(colonColon()); @@ -1143,7 +1143,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(EnumModelItem enumIte // Register all enum values on Type database const EnumeratorList &enumerators = enumItem->enumerators(); - for (EnumeratorModelItem e : enumItem->enumerators()) { + for (const EnumeratorModelItem &e : enumerators) { QString name; if (enclosing) { name += enclosing->name(); @@ -1645,8 +1645,8 @@ AbstractMetaFunctionList AbstractMetaBuilderPrivate::templateClassFunctionList(c } } - const AbstractMetaFunctionList::ConstIterator unchangedBegin = unchangedFunctions.begin(); - const AbstractMetaFunctionList::ConstIterator unchangedEnd = unchangedFunctions.end(); + const AbstractMetaFunctionList::ConstIterator unchangedBegin = unchangedFunctions.cbegin(); + const AbstractMetaFunctionList::ConstIterator unchangedEnd = unchangedFunctions.cend(); for (int i = result.size() - 1; i >= 0; --i) { AbstractMetaFunction *function = result.at(i); if (!unchangedFunctions.contains(function) @@ -1802,10 +1802,10 @@ bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass) QStringList baseClasses = metaClass->baseClassNames(); // we only support our own containers and ONLY if there is only one baseclass - if (baseClasses.size() == 1 && baseClasses.first().contains(QLatin1Char('<'))) { + if (baseClasses.size() == 1 && baseClasses.constFirst().contains(QLatin1Char('<'))) { TypeParser::Info info; ComplexTypeEntry* baseContainerType; - AbstractMetaClass* templ = findTemplateClass(baseClasses.first(), metaClass, &info, &baseContainerType); + AbstractMetaClass* templ = findTemplateClass(baseClasses.constFirst(), metaClass, &info, &baseContainerType); if (templ) { setupInheritance(templ); inheritTemplate(metaClass, templ, info); @@ -1827,7 +1827,7 @@ bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass) qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("template baseclass '%1' of '%2' is not known") - .arg(baseClasses.first(), metaClass->name()); + .arg(baseClasses.constFirst(), metaClass->name()); return false; } @@ -1998,7 +1998,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu if (metaFunction->name() == metaClass->name()) { metaFunction->setFunctionType(AbstractMetaFunction::ConstructorFunction); if (fargs.size() == 1) { - const TypeEntry *te = fargs.first()->type()->typeEntry(); + const TypeEntry *te = fargs.constFirst()->type()->typeEntry(); if (te->isCustom()) metaFunction->setExplicit(true); if (te->name() == metaFunction->name()) @@ -2258,7 +2258,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel if (arguments.size() == 1) { ArgumentModelItem arg = arguments.at(0); TypeInfo type = arg->type(); - if (type.qualifiedName().first() == QLatin1String("void") && type.indirections() == 0) + if (type.qualifiedName().constFirst() == QLatin1String("void") && type.indirections() == 0) arguments.pop_front(); } @@ -2322,9 +2322,9 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel } else { FunctionModificationList mods = TypeDatabase::instance()->functionModifications(metaFunction->minimalSignature()); if (!mods.isEmpty()) { - QVector<ArgumentModification> argMods = mods.first().argument_mods; + QVector<ArgumentModification> argMods = mods.constFirst().argument_mods; if (!argMods.isEmpty()) - replacedExpression = argMods.first().replacedDefaultExpression; + replacedExpression = argMods.constFirst().replacedDefaultExpression; } } @@ -2373,7 +2373,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel // Determine class special functions if (m_currentClass && metaFunction->arguments().size() == 1) { - const AbstractMetaType *argType = metaFunction->arguments().first()->type(); + const AbstractMetaType *argType = metaFunction->arguments().constFirst()->type(); if (argType->typeEntry() == m_currentClass->typeEntry() && argType->indirections() == 0) { if (metaFunction->name() == QLatin1String("operator=")) { switch (argType->referenceType()) { @@ -3034,10 +3034,8 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass, QString templateParamName; for (const QString &possibleName : qAsConst(possibleNames)) { t = typeDb->findType(possibleName); - if (t) { - QString templateParamName = possibleName; + if (t) break; - } } if (t) { @@ -3185,8 +3183,6 @@ void AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass, continue; } - QString typeName = scope + l.at(0); - QPropertySpec* spec = new QPropertySpec(type->typeEntry()); spec->setName(l.at(1)); spec->setIndex(i); diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h index 71b69473e..9e15541f6 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h @@ -56,7 +56,7 @@ public: void pushScope(ScopeModelItem item) { m_scopes << item; } - ScopeModelItem currentScope() const { return m_scopes.last(); } + ScopeModelItem currentScope() const { return m_scopes.constLast(); } AbstractMetaClass *argumentToClass(ArgumentModelItem); diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 19e6a0f26..840466108 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -1326,7 +1326,6 @@ void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList &functions) // Functions must be sorted by name before next loop sortFunctions(); - QString currentName; for (AbstractMetaFunction *f : qAsConst(m_functions)) { f->setOwnerClass(this); diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp index 404e0bea6..6508d378a 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp @@ -46,7 +46,7 @@ ApiExtractor::ApiExtractor() : m_builder(0) { // Environment TYPESYSTEMPATH - QString envTypesystemPaths = QFile::decodeName(getenv("TYPESYSTEMPATH")); + QString envTypesystemPaths = QFile::decodeName(qgetenv("TYPESYSTEMPATH")); if (!envTypesystemPaths.isEmpty()) TypeDatabase::instance()->addTypesystemPath(envTypesystemPaths); } diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 171adc2d6..1ed054d91 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -533,6 +533,13 @@ static inline bool compareHeaderName(const char *haystack, const char *needle) #endif } +#ifdef Q_OS_UNIX +static bool cStringStartsWith(const char *prefix, const char *str) +{ + return strncmp(prefix, str, strlen(prefix)) == 0; +} +#endif + bool Builder::visitLocation(const CXSourceLocation &location) const { if (clang_Location_isInSystemHeader(location) == 0) @@ -546,7 +553,21 @@ bool Builder::visitLocation(const CXSourceLocation &location) const // Has been observed to be 0 for invalid locations if (const char *cFileName = clang_getCString(cxFileName)) { // Resolve OpenGL typedefs although the header is considered a system header. - const bool visitHeader = compareHeaderName(cFileName, "gl.h"); + const bool visitHeader = compareHeaderName(cFileName, "gl.h") +#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) + || cStringStartsWith("/usr/include/stdint.h", cFileName) +#endif +#if defined(Q_OS_LINUX) + || cStringStartsWith("/usr/include/stdlib.h", cFileName) + || cStringStartsWith("/usr/include/sys/types.h", cFileName) +#elif defined(Q_OS_MACOS) + // Parse the following system headers to get the correct typdefs for types like + // int32_t, which are used in the macOS implementation of OpenGL framework. + || compareHeaderName(cFileName, "gltypes.h") + || cStringStartsWith("/usr/include/_types", cFileName) + || cStringStartsWith("/usr/include/sys/_types", cFileName) +#endif + ; clang_disposeString(cxFileName); if (visitHeader) return true; diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp index ea08ff6f9..16a7a3147 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp @@ -260,7 +260,7 @@ bool parse(const QByteArrayList &clangArgs, unsigned clangFlags, BaseVisitor &b debug.nospace(); debug << "Errors in " << QDir::toNativeSeparators(QFile::decodeName(clangArgs.constLast())) << ":\n"; - for (const Diagnostic &diagnostic : diagnostics) + for (const Diagnostic &diagnostic : qAsConst(diagnostics)) debug << diagnostic << '\n'; } diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp index fdc8d3312..f30a585bc 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp @@ -163,7 +163,7 @@ QVector<Diagnostic> getDiagnostics(CXTranslationUnit tu) CXDiagnosticSeverity maxSeverity(const QVector<Diagnostic> &ds) { CXDiagnosticSeverity result = CXDiagnostic_Ignored; - for (const Diagnostic d : ds) { + for (const Diagnostic& d : ds) { if (d.severity > result) result = d.severity; } diff --git a/sources/shiboken2/ApiExtractor/fileout.cpp b/sources/shiboken2/ApiExtractor/fileout.cpp index c97347fe1..be0023c3c 100644 --- a/sources/shiboken2/ApiExtractor/fileout.cpp +++ b/sources/shiboken2/ApiExtractor/fileout.cpp @@ -39,15 +39,15 @@ bool FileOut::dummy = false; bool FileOut::diff = false; #ifdef Q_OS_LINUX -const char* colorDelete = "\033[31m"; -const char* colorAdd = "\033[32m"; -const char* colorInfo = "\033[36m"; -const char* colorReset = "\033[0m"; +static const char colorDelete[] = "\033[31m"; +static const char colorAdd[] = "\033[32m"; +static const char colorInfo[] = "\033[36m"; +static const char colorReset[] = "\033[0m"; #else -const char* colorDelete = ""; -const char* colorAdd = ""; -const char* colorInfo = ""; -const char* colorReset = ""; +static const char colorDelete[] = ""; +static const char colorAdd[] = ""; +static const char colorInfo[] = ""; +static const char colorReset[] = ""; #endif FileOut::FileOut(QString n): diff --git a/sources/shiboken2/ApiExtractor/graph.cpp b/sources/shiboken2/ApiExtractor/graph.cpp index e6ee660dc..6ba4d994a 100644 --- a/sources/shiboken2/ApiExtractor/graph.cpp +++ b/sources/shiboken2/ApiExtractor/graph.cpp @@ -127,8 +127,7 @@ void Graph::dumpDot(const QHash< int, QString >& nodeNames, const QString& fileN QTextStream s(&output); s << "digraph D {\n"; for (int i = 0; i < m_d->edges.size(); ++i) { - GraphPrivate::EdgeIterator it = m_d->edges[i].begin(); - for (;it != m_d->edges[i].end(); ++it) + for (auto it = m_d->edges[i].cbegin(), end = m_d->edges[i].cend(); it != end; ++it) s << '"' << nodeNames[i] << "\" -> \"" << nodeNames[*it] << "\"\n"; } s << "}\n"; diff --git a/sources/shiboken2/ApiExtractor/header_paths.h b/sources/shiboken2/ApiExtractor/header_paths.h index 3bc26efe0..f70709b7c 100644 --- a/sources/shiboken2/ApiExtractor/header_paths.h +++ b/sources/shiboken2/ApiExtractor/header_paths.h @@ -46,12 +46,16 @@ public: { QByteArray option; - if (p.m_isFramework) - option = QByteArrayLiteral("-F"); - else if (systemInclude) + if (p.m_isFramework) { + if (systemInclude) + option = QByteArrayLiteral("-iframework"); + else + option = QByteArrayLiteral("-F"); + } else if (systemInclude) { option = QByteArrayLiteral("-isystem"); - else + } else { option = QByteArrayLiteral("-I"); + } return option + p.path; } diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index c6f723e4d..4a8d3063d 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -373,6 +373,7 @@ bool Handler::endElement(const QStringRef &localName) m_current->parent->entry->setCodeSnips(snips); break; } + Q_FALLTHROUGH(); case StackElement::NativeToTarget: case StackElement::AddConversion: m_contextStack.top()->codeSnips.last().addTemplateInstance(m_current->value.templateInstance); @@ -614,11 +615,10 @@ void Handler::addFlags(const QString &name, QString flagName, if (QStringList(lst.mid(0, lst.size() - 1)).join(colonColon()) != m_currentEnum->targetLangQualifier()) { qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("enum %1 and flags %2 differ in qualifiers") - // avoid constFirst to stay Qt 5.5 compatible - .arg(m_currentEnum->targetLangQualifier(), lst.first()); + .arg(m_currentEnum->targetLangQualifier(), lst.constFirst()); } - ftype->setFlagsName(lst.last()); + ftype->setFlagsName(lst.constLast()); m_currentEnum->setFlags(ftype); m_database->addFlagsType(ftype); @@ -756,20 +756,20 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts break; case StackElement::ValueTypeEntry: attributes.insert(QLatin1String("default-constructor"), QString()); - // fall throooough + Q_FALLTHROUGH(); case StackElement::ObjectTypeEntry: attributes.insert(QLatin1String("force-abstract"), QLatin1String("no")); attributes.insert(QLatin1String("deprecated"), QLatin1String("no")); attributes.insert(QLatin1String("hash-function"), QString()); attributes.insert(QLatin1String("stream"), QLatin1String("no")); - // fall throooough + Q_FALLTHROUGH(); case StackElement::InterfaceTypeEntry: attributes[QLatin1String("default-superclass")] = m_defaultSuperclass; attributes.insert(QLatin1String("polymorphic-id-expression"), QString()); attributes.insert(QLatin1String("delete-in-main-thread"), QLatin1String("no")); attributes.insert(QLatin1String("held-type"), QString()); attributes.insert(QLatin1String("copyable"), QString()); - // fall through + Q_FALLTHROUGH(); case StackElement::NamespaceTypeEntry: attributes.insert(QLatin1String("target-lang-name"), QString()); attributes[QLatin1String("package")] = m_defaultPackage; @@ -932,7 +932,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts else m_currentEnum = new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join(colonColon()), - names.last(), since); + names.constLast(), since); m_currentEnum->setAnonymous(!attributes[QLatin1String("identified-by-value")].isEmpty()); element->entry = m_currentEnum; m_currentEnum->setCodeGeneration(m_generate); @@ -968,7 +968,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts itype->setOrigin(otype); element->entry = otype; } - // fall through + Q_FALLTHROUGH(); case StackElement::ValueTypeEntry: { if (!element->entry) { ValueTypeEntry* typeEntry = new ValueTypeEntry(name, since); @@ -978,12 +978,12 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts element->entry = typeEntry; } - // fall through + Q_FALLTHROUGH(); case StackElement::NamespaceTypeEntry: if (!element->entry) element->entry = new NamespaceTypeEntry(name, since); - // fall through + Q_FALLTHROUGH(); case StackElement::ObjectTypeEntry: if (!element->entry) element->entry = new ObjectTypeEntry(name, since); @@ -1334,13 +1334,12 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts } } break; - case StackElement::RejectEnumValue: { + case StackElement::RejectEnumValue: if (!m_currentEnum) { m_error = QLatin1String("<reject-enum-value> node must be used inside a <enum-type> node"); return false; } - QString name = attributes[nameAttribute()]; - } break; + break; case StackElement::ReplaceType: { if (topElement.type != StackElement::ModifyArgument) { m_error = QLatin1String("Type replacement can only be specified for argument modifications"); @@ -1978,7 +1977,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts } if (topElement.type == StackElement::ModifyFunction || topElement.type == StackElement::AddFunction) { - FunctionModification mod = m_contextStack.top()->functionMods.last(); + FunctionModification mod = m_contextStack.top()->functionMods.constLast(); if (snip.language == TypeSystem::ShellDeclaration) { m_error = QLatin1String("no function implementation in shell declaration in which to inject code"); return false; @@ -2495,7 +2494,7 @@ AddedFunction::AddedFunction(QString signature, QString returnType, double vr) : break; } // is const? - m_isConst = signature.right(signatureLength - endPos).contains(QLatin1String("const")); + m_isConst = signature.rightRef(signatureLength - endPos).contains(QLatin1String("const")); } } diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index 288de8117..b9dd0a7f9 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -302,6 +302,12 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE) set(SHIBOKEN_BUILD_TYPE "Release") + +# We do not want to link against the python shared / static library on Linux And macOS. +# The dynamic linker will pick up the python symbols at runtime automatically. +# On Windows we do need to link against the python.lib import library. + +set(SBK_PYTHON_LIBRARIES "") if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT PYTHON_DEBUG_LIBRARIES) message(WARNING "Python debug shared library not found; assuming python was built with shared library support disabled.") @@ -321,10 +327,14 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(SBK_PKG_CONFIG_PY_DEBUG_DEFINITION "${SBK_PKG_CONFIG_PY_DEBUG_DEFINITION} -DCOUNT_ALLOCS") endif() - set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) + if(WIN32) + set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) + endif() set(SHIBOKEN_BUILD_TYPE "Debug") else() - set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) + if(WIN32) + set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) + endif() add_definitions("-DNDEBUG") endif() diff --git a/sources/shiboken2/data/Shiboken2Config.cmake.in b/sources/shiboken2/data/Shiboken2Config.cmake.in index 515b0d13b..7891c5a2d 100644 --- a/sources/shiboken2/data/Shiboken2Config.cmake.in +++ b/sources/shiboken2/data/Shiboken2Config.cmake.in @@ -2,4 +2,4 @@ if (NOT PYTHON_CONFIG_SUFFIX) message(STATUS "Shiboken2Config: Using default python: @PYTHON_CONFIG_SUFFIX@") SET(PYTHON_CONFIG_SUFFIX @PYTHON_CONFIG_SUFFIX@) endif() -include(@LIB_INSTALL_DIR@/cmake/Shiboken2-@shiboken2_VERSION@/Shiboken2Config${PYTHON_CONFIG_SUFFIX}.cmake) +include("@LIB_INSTALL_DIR@/cmake/Shiboken2-@shiboken2_VERSION@/Shiboken2Config${PYTHON_CONFIG_SUFFIX}.cmake") diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index a8e8735bb..71647a1c5 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -127,7 +127,7 @@ void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType QString piece = isContainer ? QStringLiteral("container") : QStringLiteral("smart pointer"); QString warning = QString::fromLatin1("Skipping instantiation of %1 '%2' because it has template" - " arguments.").arg(piece).arg(type->originalTypeDescription()); + " arguments.").arg(piece, type->originalTypeDescription()); if (!context.isEmpty()) warning.append(QStringLiteral(" Calling context: %1").arg(context)); @@ -443,7 +443,7 @@ QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor) for (QString line : lst) { if (!line.isEmpty() && !emptyLine.match(line).hasMatch()) { - while (line.end()->isSpace()) + while (line.constEnd()->isSpace()) line.chop(1); int limit = 0; for(int i = 0; i < spacesToRemove; ++i) { diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index b22919981..774775fb0 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -218,7 +218,7 @@ static QMap<QString, QString> getInitializedArguments() { QMap<QString, QString> args; QStringList arguments = QCoreApplication::arguments(); - QString appName = arguments.first(); + QString appName = arguments.constFirst(); arguments.removeFirst(); QString projectFileName; @@ -502,9 +502,8 @@ int main(int argc, char *argv[]) QStringList parts = fullVersion.split(QLatin1Char(',')); QString package; QString version; - // avoid constFirst to stay Qt 5.5 compatible - package = parts.count() == 1 ? QLatin1String("*") : parts.first(); - version = parts.last(); + package = parts.count() == 1 ? QLatin1String("*") : parts.constFirst(); + version = parts.constLast(); if (!extractor.setApiVersion(package, version)) { errorPrint(msgInvalidVersion(package, version)); return EXIT_FAILURE; diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index e9d801044..392f5b66d 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -393,7 +393,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) if (overloads.isEmpty()) continue; - const AbstractMetaFunction* rfunc = overloads.first(); + const AbstractMetaFunction* rfunc = overloads.constFirst(); if (m_sequenceProtocol.contains(rfunc->name()) || m_mappingProtocol.contains(rfunc->name())) continue; @@ -429,7 +429,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) AbstractMetaType *pointerToInnerType = buildAbstractMetaTypeFromString(pointerToInnerTypeName); - AbstractMetaFunction *mutableRfunc = overloads.first(); + AbstractMetaFunction *mutableRfunc = overloads.constFirst(); mutableRfunc->replaceType(pointerToInnerType); } else if (smartPointerTypeEntry->refCountMethodName().isEmpty() || smartPointerTypeEntry->refCountMethodName() != rfunc->name()) { @@ -611,7 +611,7 @@ void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunc s << " : "; writeFunctionCall(s, func); s << " {" << endl; - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg); s << INDENT << "// ... middle" << endl; writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg); @@ -701,7 +701,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun qCWarning(lcShiboken) << "The expression used in return value contains an invalid index."; break; } - defaultReturnExpr.replace(match.captured(0), func->arguments()[argId]->name()); + defaultReturnExpr.replace(match.captured(0), func->arguments().at(argId)->name()); offset = match.capturedStart(1); } } @@ -733,7 +733,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun //Write declaration/native injected code if (func->hasInjectedCode()) { CodeSnipList snips = func->injectedCodeSnips(); - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionDeclaration, TypeSystem::NativeCode, func, lastArg); s << endl; } @@ -756,7 +756,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun CodeSnipList snips; if (func->hasInjectedCode()) { snips = func->injectedCodeSnips(); - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::ShellCode, func, lastArg); s << endl; } @@ -856,7 +856,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun if (injectedCodeUsesPySelf(func)) s << INDENT << "PyObject* pySelf = BindingManager::instance().retrieveWrapper(this);" << endl; - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg); s << endl; } @@ -956,7 +956,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun if (func->hasInjectedCode()) { s << endl; - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg); } @@ -1046,7 +1046,6 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry* { if (!enumType) return; - QString enumFlagName = enumType->isFlags() ? QLatin1String("flag") : QLatin1String("enum"); QString typeName = fixedCppTypeName(enumType); QString enumPythonType = cpythonTypeNameExt(enumType); QString cppTypeName = getFullTypeName(enumType).trimmed(); @@ -1258,7 +1257,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla // Constructor that does implicit conversion. if (!conv->typeReplaced(1).isEmpty()) continue; - const AbstractMetaType* sourceType = conv->arguments().first()->type(); + const AbstractMetaType* sourceType = conv->arguments().constFirst()->type(); typeCheck = cpythonCheckFunction(sourceType); bool isUserPrimitiveWithoutTargetLangName = isUserPrimitive(sourceType) && sourceType->typeEntry()->targetLangApiName() == sourceType->typeEntry()->name(); @@ -1302,7 +1301,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla } const AbstractMetaType* sourceType = conv->isConversionOperator() ? buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass()) - : conv->arguments().first()->type(); + : conv->arguments().constFirst()->type(); writePythonToCppConversionFunctions(s, sourceType, targetType, typeCheck, toCppConv, toCppPreConv); } @@ -1418,7 +1417,7 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas // Constructor that does implicit conversion. if (!conv->typeReplaced(1).isEmpty()) continue; - sourceType = conv->arguments().first()->type(); + sourceType = conv->arguments().constFirst()->type(); } QString toCpp = pythonToCppFunctionName(sourceType, targetType); QString isConv = convertibleToCppFunctionName(sourceType, targetType); @@ -1627,7 +1626,7 @@ void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFun // (first "1") and the flag indicating that the Python wrapper holds an C++ wrapper // is marked as true (the second "1"). Otherwise the default values apply: // Python owns it and C++ wrapper is false. - if (shouldGenerateCppWrapper(overloads.first()->ownerClass())) + if (shouldGenerateCppWrapper(overloads.constFirst()->ownerClass())) s << INDENT << "Shiboken::Object::setHasCppWrapper(sbkSelf, true);" << endl; // Need to check if a wrapper for same pointer is already registered // Caused by bug PYSIDE-217, where deleted objects' wrappers are not released @@ -2515,7 +2514,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov if (func->isConstructor() && func->arguments().count() == 1) { const AbstractMetaClass* ownerClass = func->ownerClass(); const ComplexTypeEntry* baseContainerType = ownerClass->typeEntry()->baseContainerType(); - if (baseContainerType && baseContainerType == func->arguments().first()->type()->typeEntry() && isCopyable(ownerClass)) { + if (baseContainerType && baseContainerType == func->arguments().constFirst()->type()->typeEntry() && isCopyable(ownerClass)) { tck << '!' << cpythonCheckFunction(ownerClass->typeEntry()) << pyArgName << ')' << endl; Indentation indent(INDENT); tck << INDENT << "&& "; @@ -2530,17 +2529,17 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov if (od->nextOverloadData().isEmpty() || od->nextArgumentHasDefaultValue() || od->nextOverloadData().size() != 1 - || od->overloads().size() != od->nextOverloadData().first()->overloads().size()) { + || od->overloads().size() != od->nextOverloadData().constFirst()->overloads().size()) { overloadData = od; od = 0; } else { - od = od->nextOverloadData().first(); + od = od->nextOverloadData().constFirst(); } } if (usePyArgs && signatureFound) { AbstractMetaArgumentList args = refFunc->arguments(); - int lastArgIsVarargs = (int) (args.size() > 1 && args.last()->type()->isVarargs()); + int lastArgIsVarargs = (int) (args.size() > 1 && args.constLast()->type()->isVarargs()); int numArgs = args.size() - OverloadData::numberOfRemovedArguments(refFunc) - lastArgIsVarargs; typeChecks.prepend(QString::fromLatin1("numArgs %1 %2").arg(lastArgIsVarargs ? QLatin1String(">=") : QLatin1String("==")).arg(numArgs)); } else if (sequenceArgCount > 1) { @@ -2584,7 +2583,7 @@ void CppGenerator::writeFunctionCalls(QTextStream &s, const OverloadData &overlo { Indentation indent(INDENT); if (overloads.count() == 1) { - writeSingleFunctionCall(s, overloadData, overloads.first(), context); + writeSingleFunctionCall(s, overloadData, overloads.constFirst(), context); } else { for (int i = 0; i < overloads.count(); i++) { const AbstractMetaFunction* func = overloads.at(i); @@ -2895,7 +2894,7 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const Abs QString code; QTextStream c(&code); c << INDENT << QString::fromLatin1("%1& cppOutRef = *((%1*)cppOut);").arg(cppTypeName) << endl; - code.append(toCppConversions.first()->conversion()); + code.append(toCppConversions.constFirst()->conversion()); for (int i = 0; i < containerType->instantiations().count(); ++i) { const AbstractMetaType* type = containerType->instantiations().at(i); QString typeName = getFullTypeName(type); @@ -2981,7 +2980,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMe } } s << INDENT << '}' << endl; - if (arg != args.last()) + if (arg != args.constLast()) s << INDENT; } } @@ -3069,7 +3068,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f removedArgs++; } } else if (maxArgs != 0 && !func->arguments().isEmpty()) { - lastArg = func->arguments().last(); + lastArg = func->arguments().constLast(); } writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func, lastArg); @@ -3144,7 +3143,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f firstArg.remove(1, 1); // remove the de-reference operator QString secondArg = QLatin1String(CPP_ARG0); - if (!func->isUnaryOperator() && shouldDereferenceArgumentPointer(func->arguments().first())) { + if (!func->isUnaryOperator() && shouldDereferenceArgumentPointer(func->arguments().constFirst())) { secondArg.prepend(QLatin1String("(*")); secondArg.append(QLatin1Char(')')); } @@ -3385,7 +3384,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f } else if (!refcount_mods.isEmpty()) { for (const ArgumentModification &arg_mod : qAsConst(refcount_mods)) { - ReferenceCount refCount = arg_mod.referenceCounts.first(); + ReferenceCount refCount = arg_mod.referenceCounts.constFirst(); if (refCount.action != ReferenceCount::Set && refCount.action != ReferenceCount::Remove && refCount.action != ReferenceCount::Add) { @@ -3411,7 +3410,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f s << INDENT << "Shiboken::Object::removeReference("; s << "reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR "), \""; - QString varName = arg_mod.referenceCounts.first().varName; + QString varName = arg_mod.referenceCounts.constFirst().varName; if (varName.isEmpty()) varName = func->minimalSignature() + QString().number(arg_mod.index); @@ -3724,8 +3723,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s, tp_dealloc = QLatin1String("&SbkDeallocQAppWrapper"); else tp_dealloc = QLatin1String("&SbkDeallocWrapper"); - // avoid constFirst to stay Qt 5.5 compatible - tp_init = (onlyPrivCtor || ctors.isEmpty()) ? QLatin1String("0") : cpythonFunctionName(ctors.first()); + tp_init = (onlyPrivCtor || ctors.isEmpty()) ? QLatin1String("0") : cpythonFunctionName(ctors.constFirst()); } QString tp_getattro(QLatin1Char('0')); @@ -3872,11 +3870,7 @@ void CppGenerator::writeMappingMethods(QTextStream &s, const AbstractMetaClass *metaClass, GeneratorContext &context) { - - QMap<QString, QString> funcs; - - QHash< QString, QPair< QString, QString > >::const_iterator it = m_mappingProtocol.begin(); - for (; it != m_mappingProtocol.end(); ++it) { + for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) { const AbstractMetaFunction* func = metaClass->findFunction(it.key()); if (!func) continue; @@ -3890,7 +3884,7 @@ void CppGenerator::writeMappingMethods(QTextStream &s, writeCppSelfDefinition(s, func, context); - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg); s << '}' << endl << endl; } @@ -3900,12 +3894,9 @@ void CppGenerator::writeSequenceMethods(QTextStream &s, const AbstractMetaClass *metaClass, GeneratorContext &context) { - - QMap<QString, QString> funcs; bool injectedCode = false; - QHash< QString, QPair< QString, QString > >::const_iterator it = m_sequenceProtocol.begin(); - for (; it != m_sequenceProtocol.end(); ++it) { + for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) { const AbstractMetaFunction* func = metaClass->findFunction(it.key()); if (!func) continue; @@ -3920,7 +3911,7 @@ void CppGenerator::writeSequenceMethods(QTextStream &s, writeCppSelfDefinition(s, func, context); - const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last(); + const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, snips,TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg); s << '}' << endl << endl; } @@ -3984,7 +3975,7 @@ void CppGenerator::writeTypeAsMappingDefinition(QTextStream& s, const AbstractMe QString baseName = cpythonBaseName(metaClass); s << INDENT << "memset(&" << baseName << "_TypeAsMapping, 0, sizeof(PyMappingMethods));" << endl; - for (QHash<QString, QString>::const_iterator it = m_mpFuncs.cbegin(), end = m_mpFuncs.end(); it != end; ++it) { + for (auto it = m_mpFuncs.cbegin(), end = m_mpFuncs.cend(); it != end; ++it) { const QString &mpName = it.key(); if (funcs[mpName].isEmpty()) continue; @@ -4279,7 +4270,7 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co int alternativeNumericTypes = 0; for (const AbstractMetaFunction *func : overloads) { if (!func->isStatic() && - ShibokenGenerator::isNumber(func->arguments()[0]->type()->typeEntry())) + ShibokenGenerator::isNumber(func->arguments().at(0)->type()->typeEntry())) alternativeNumericTypes++; } @@ -4312,7 +4303,7 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co // If the function is user added, use the inject code if (func->isUserAdded()) { CodeSnipList snips = func->injectedCodeSnips(); - writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, func->arguments().last()); + writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, func->arguments().constLast()); } else { QString expression = QString::fromLatin1("%1%2 %3 (%4" CPP_ARG0 ")") .arg(func->isPointerOperator() ? QLatin1String("&") : QString(), @@ -4393,7 +4384,7 @@ void CppGenerator::writeMethodDefinitionEntry(QTextStream& s, const AbstractMeta void CppGenerator::writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList overloads) { Q_ASSERT(!overloads.isEmpty()); - const AbstractMetaFunction* func = overloads.first(); + const AbstractMetaFunction* func = overloads.constFirst(); if (m_tpFuncs.contains(func->name())) return; @@ -4977,7 +4968,7 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorCont const AbstractMetaClass* enclosingClass = metaClass->enclosingClass(); while (enclosingClass) { if (enclosingClass->typeEntry()->generateCode()) - nameVariants << (enclosingClass->name() + QLatin1String("::") + nameVariants.last()); + nameVariants << (enclosingClass->name() + QLatin1String("::") + nameVariants.constLast()); enclosingClass = enclosingClass->enclosingClass(); } @@ -5778,7 +5769,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext & s << INDENT << metaClass->qualifiedCppName() << "::iterator _item = " CPP_SELF_VAR "->begin();" << endl; s << INDENT << "for (Py_ssize_t pos = 0; pos < _i; pos++) _item++;" << endl; - const AbstractMetaType* itemType = metaClass->templateBaseClassInstantiations().first(); + const AbstractMetaType* itemType = metaClass->templateBaseClassInstantiations().constFirst(); s << INDENT << "return "; writeToPythonConversion(s, itemType, metaClass, QLatin1String("*_item")); diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp index 0c3cf93f6..f6bd2cd7e 100644 --- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp @@ -417,7 +417,7 @@ bool HeaderGenerator::finishGeneration() // TODO-CONVERTER ------------------------------------------------------------------------------ macrosStream << "// Macros for type check" << endl; - for (const AbstractMetaEnum *cppEnum : globalEnums) { + for (const AbstractMetaEnum *cppEnum : qAsConst(globalEnums)) { if (cppEnum->isAnonymous() || cppEnum->isPrivate()) continue; includes << cppEnum->typeEntry()->include(); diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 876185cbe..3340ee957 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -94,7 +94,7 @@ static bool typesAreEqual(const AbstractMetaType* typeA, const AbstractMetaType* */ struct OverloadSortData { - OverloadSortData() : counter(0) {}; + OverloadSortData() : counter(0) {} /** * Adds a typeName into the type map without associating it with @@ -142,7 +142,7 @@ static QString getImplicitConversionTypeName(const AbstractMetaType* containerTy else if (function->isConversionOperator()) impConv = function->ownerClass()->typeEntry()->name(); else - impConv = getTypeName(function->arguments().first()->type()); + impConv = getTypeName(function->arguments().constFirst()->type()); QStringList types; const AbstractMetaTypeList &instantiations = containerType->instantiations(); @@ -211,7 +211,7 @@ void OverloadData::sortNextOverloads() << QLatin1String("long"); // sort the children overloads - for (OverloadData *ov : m_nextOverloadData) + for (OverloadData *ov : qAsConst(m_nextOverloadData)) ov->sortNextOverloads(); if (m_nextOverloadData.size() <= 1) @@ -220,7 +220,7 @@ void OverloadData::sortNextOverloads() // Populates the OverloadSortData object containing map and reverseMap, to map type names to ids, // these ids will be used by the topological sort algorithm, because is easier and faster to work // with graph sorting using integers. - for (OverloadData *ov : m_nextOverloadData) { + for (OverloadData *ov : qAsConst(m_nextOverloadData)) { sortData.mapType(ov); const QString typeName(getTypeName(ov)); @@ -293,7 +293,7 @@ void OverloadData::sortNextOverloads() MetaFunctionList involvedConversions; - for (OverloadData *ov : m_nextOverloadData) { + for (OverloadData *ov : qAsConst(m_nextOverloadData)) { const AbstractMetaType* targetType = ov->argType(); const QString targetTypeEntryName(getTypeName(ov)); int targetTypeId = sortData.map[targetTypeEntryName]; @@ -305,7 +305,7 @@ void OverloadData::sortNextOverloads() if (function->isConversionOperator()) convertibleType = function->ownerClass()->typeEntry()->name(); else - convertibleType = getTypeName(function->arguments().first()->type()); + convertibleType = getTypeName(function->arguments().constFirst()->type()); if (convertibleType == QLatin1String("int") || convertibleType == QLatin1String("unsigned int")) classesWithIntegerImplicitConversion << targetTypeEntryName; @@ -323,7 +323,7 @@ void OverloadData::sortNextOverloads() } // Process inheritance relationships - if (targetType->isValue() || targetType->isObject()) { + if (targetType->isValue() || targetType->isObject() || targetType->isQObject()) { const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), targetType->typeEntry()); const AbstractMetaClassList &ancestors = m_generator->getAllAncestors(metaClass); for (const AbstractMetaClass *ancestor : ancestors) { @@ -404,7 +404,7 @@ void OverloadData::sortNextOverloads() if (sortData.map.contains(QLatin1String("QString")) && sortData.map.contains(QLatin1String("QByteArray"))) graph.addEdge(sortData.map[QLatin1String("QString")], sortData.map[QLatin1String("QByteArray")]); - for (OverloadData *ov : m_nextOverloadData) { + for (OverloadData *ov : qAsConst(m_nextOverloadData)) { const AbstractMetaType* targetType = ov->argType(); if (!targetType->isEnum()) continue; @@ -435,9 +435,8 @@ void OverloadData::sortNextOverloads() // Dump overload graph QString graphName = QDir::tempPath() + QLatin1Char('/') + funcName + QLatin1String(".dot"); - QHash<QString, int>::const_iterator it = sortData.map.begin(); QHash<int, QString> nodeNames; - for (; it != sortData.map.end(); ++it) + for (auto it = sortData.map.cbegin(), end = sortData.map.cend(); it != end; ++it) nodeNames.insert(it.value(), it.key()); graph.dumpDot(nodeNames, graphName); qCWarning(lcShiboken).noquote() << qPrintable(msgCyclicDependency(funcName, graphName, involvedConversions)); @@ -521,7 +520,7 @@ void OverloadData::addOverload(const AbstractMetaFunction* func) for (int i = 0; m_headOverloadData->m_minArgs > 0 && i < origNumArgs; i++) { if (func->argumentRemoved(i + 1)) continue; - if (!ShibokenGenerator::getDefaultValue(func, func->arguments()[i]).isEmpty()) { + if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(i)).isEmpty()) { int fixedArgIndex = i - removed; if (fixedArgIndex < m_headOverloadData->m_minArgs) m_headOverloadData->m_minArgs = fixedArgIndex; @@ -590,7 +589,7 @@ bool OverloadData::hasVarargs() const { for (const AbstractMetaFunction *func : m_overloads) { AbstractMetaArgumentList args = func->arguments(); - if (args.size() > 1 && args.last()->type()->isVarargs()) + if (args.size() > 1 && args.constLast()->type()->isVarargs()) return true; } return false; @@ -653,7 +652,7 @@ bool OverloadData::hasStaticAndInstanceFunctions() const const AbstractMetaFunction* OverloadData::referenceFunction() const { - return m_overloads.first(); + return m_overloads.constFirst(); } const AbstractMetaArgument* OverloadData::argument(const AbstractMetaFunction* func) const @@ -670,7 +669,7 @@ const AbstractMetaArgument* OverloadData::argument(const AbstractMetaFunction* f argPos++; } - return func->arguments()[m_argPos + removed]; + return func->arguments().at(m_argPos + removed); } OverloadDataList OverloadData::overloadDataOnPosition(OverloadData* overloadData, int argPos) const @@ -755,7 +754,7 @@ const AbstractMetaFunction* OverloadData::getFunctionWithDefaultValue() const if (func->argumentRemoved(i + 1)) removedArgs++; } - if (!ShibokenGenerator::getDefaultValue(func, func->arguments()[m_argPos + removedArgs]).isEmpty()) + if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(m_argPos + removedArgs)).isEmpty()) return func; } return 0; @@ -822,7 +821,7 @@ QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList& if (func->argumentRemoved(j + 1)) continue; int fixedArgIndex = j - removed; - if (fixedArgIndex < minArgs && !ShibokenGenerator::getDefaultValue(func, func->arguments()[j]).isEmpty()) + if (fixedArgIndex < minArgs && !ShibokenGenerator::getDefaultValue(func, func->arguments().at(j)).isEmpty()) minArgs = fixedArgIndex; } } diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 5a6d5fc17..82f21f6d0 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -495,7 +495,7 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction* if (prefix.isEmpty() && match.hasMatch()) { QString flagName = match.captured(1); QStringList enumItems = match.captured(2).split(QLatin1Char('|')); - QString scope = searchForEnumScope(func->implementingClass(), enumItems.first()); + QString scope = searchForEnumScope(func->implementingClass(), enumItems.constFirst()); if (!scope.isEmpty()) scope.append(QLatin1String("::")); @@ -1019,7 +1019,7 @@ bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaCla AbstractMetaFunctionList ctors = metaClass->queryFunctions(AbstractMetaClass::Constructors); if (ctors.count() != 1) return false; - return ctors.first()->functionType() == AbstractMetaFunction::CopyConstructorFunction; + return ctors.constFirst()->functionType() == AbstractMetaFunction::CopyConstructorFunction; } bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const @@ -1123,7 +1123,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType || type == ContainerTypeEntry::StackContainer || type == ContainerTypeEntry::SetContainer || type == ContainerTypeEntry::QueueContainer) { - const AbstractMetaType* type = metaType->instantiations().first(); + const AbstractMetaType* type = metaType->instantiations().constFirst(); if (isPointerToWrapperType(type)) { typeCheck += QString::fromLatin1("checkSequenceTypes(%1, ").arg(cpythonTypeNameExt(type)); } else if (isWrapperType(type)) { @@ -1139,8 +1139,8 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType || type == ContainerTypeEntry::MultiHashContainer || type == ContainerTypeEntry::PairContainer) { QString pyType = (type == ContainerTypeEntry::PairContainer) ? QLatin1String("Pair") : QLatin1String("Dict"); - const AbstractMetaType* firstType = metaType->instantiations().first(); - const AbstractMetaType* secondType = metaType->instantiations().last(); + const AbstractMetaType* firstType = metaType->instantiations().constFirst(); + const AbstractMetaType* secondType = metaType->instantiations().constLast(); if (isPointerToWrapperType(firstType) && isPointerToWrapperType(secondType)) { typeCheck += QString::fromLatin1("check%1Types(%2, %3, ").arg(pyType) .arg(cpythonTypeNameExt(firstType), cpythonTypeNameExt(secondType)); @@ -1966,8 +1966,8 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa while (rit.hasNext()) { const QRegularExpressionMatch match = rit.next(); const QStringList list = match.capturedTexts(); - QString conversionString = list.first(); - QString conversionTypeName = list.last(); + QString conversionString = list.constFirst(); + QString conversionTypeName = list.constLast(); const AbstractMetaType* conversionType = buildAbstractMetaTypeFromString(conversionTypeName); if (!conversionType) { qFatal(qPrintable(QString::fromLatin1("Could not find type '%1' for use in '%2' conversion. " @@ -1986,7 +1986,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa while (code.at(start).isSpace()) ++start; QString varType = code.mid(start, end - start); - conversionString = varType + list.first(); + conversionString = varType + list.constFirst(); varType = miniNormalizer(varType); QString varName = list.at(1).trimmed(); if (!varType.isEmpty()) { @@ -2193,7 +2193,7 @@ AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStatic if (overloads.isEmpty()) continue; if (OverloadData::hasStaticAndInstanceFunctions(overloads)) - methods.append(overloads.first()); + methods.append(overloads.constFirst()); } } return methods; diff --git a/sources/shiboken2/header.COMM b/sources/shiboken2/header.COMM deleted file mode 100644 index 1c8cb00e7..000000000 --- a/sources/shiboken2/header.COMM +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the <Fill> module. -** -** $QT_BEGIN_LICENSE:COMM$ -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** $QT_END_LICENSE$ -** -******************************************************************************/ diff --git a/sources/shiboken2/header.LGPL-ONLY b/sources/shiboken2/header.LGPL-ONLY deleted file mode 100644 index 9a676032e..000000000 --- a/sources/shiboken2/header.LGPL-ONLY +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt.io/contact-us/. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ diff --git a/sources/shiboken2/header.LGPL21 b/sources/shiboken2/header.LGPL21 deleted file mode 100644 index 533390b07..000000000 --- a/sources/shiboken2/header.LGPL21 +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/shiboken2/header.LGPL3 b/sources/shiboken2/header.LGPL3 deleted file mode 100644 index d9a65c2e4..000000000 --- a/sources/shiboken2/header.LGPL3 +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/shiboken2/header.LGPL3-COMM b/sources/shiboken2/header.LGPL3-COMM deleted file mode 100644 index b5dc15d38..000000000 --- a/sources/shiboken2/header.LGPL3-COMM +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3-COMM$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index fc208e520..d697d0732 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -838,13 +838,15 @@ Py_hash_t hash(PyObject* pyObj) static void setSequenceOwnership(PyObject* pyObj, bool owner) { if (PySequence_Check(pyObj)) { - std::list<SbkObject*> objs = splitPyObject(pyObj); - std::list<SbkObject*>::const_iterator it = objs.begin(); - for(; it != objs.end(); ++it) { - if (owner) - getOwnership(*it); - else - releaseOwnership(*it); + Py_ssize_t size = PySequence_Size(pyObj); + if (size > 0) { + std::list<SbkObject*> objs = splitPyObject(pyObj); + for (auto it = objs.begin(), end = objs.end(); it != end; ++it) { + if (owner) + getOwnership(*it); + else + releaseOwnership(*it); + } } } else if (Object::checkType(pyObj)) { if (owner) |