diff options
Diffstat (limited to 'sources/pyside6/PySide6/templates/gui_common.xml')
-rw-r--r-- | sources/pyside6/PySide6/templates/gui_common.xml | 73 |
1 files changed, 16 insertions, 57 deletions
diff --git a/sources/pyside6/PySide6/templates/gui_common.xml b/sources/pyside6/PySide6/templates/gui_common.xml index 1869af8bb..6a7404507 100644 --- a/sources/pyside6/PySide6/templates/gui_common.xml +++ b/sources/pyside6/PySide6/templates/gui_common.xml @@ -1,50 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 2.0 or (at your option) the GNU General -** Public license version 3 or 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.GPL2 and 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only --> <typesystem> <template name="QFontCharFix"> int size = Shiboken::String::len(%PYARG_1); if (size == 1) { const char *str = Shiboken::String::toCString(%PYARG_1); - QChar ch(str[0]); + const QChar ch(static_cast<unsigned short>(str[0])); %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ch); %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); } else { @@ -54,21 +18,24 @@ <template name="load_xpm"> Shiboken::AutoDecRef strList(PySequence_Fast(%PYARG_1, "Invalid sequence.")); - int lineCount = PySequence_Fast_GET_SIZE(strList.object()); - for (int line = 0; line < lineCount; ++line) { + Py_ssize_t lineCount = PySequence_Fast_GET_SIZE(strList.object()); + for (Py_ssize_t line = 0; line < lineCount; ++line) { if (!Shiboken::String::check(PySequence_Fast_GET_ITEM(strList.object(), line))) { PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of strings."); break; } } + // PySIDE-1735: Enums are now implemented in Python, so we need to avoid asserts. + if (PyErr_Occurred()) + break; - const char **xpm = reinterpret_cast<const char**>(malloc(lineCount * sizeof(const char**))); - for (int line = 0; line < lineCount; ++line) + auto xpm = new const char*[lineCount]; + for (Py_ssize_t line = 0; line < lineCount; ++line) xpm[line] = Shiboken::String::toCString(PySequence_Fast_GET_ITEM(strList.object(), line)); %0 = new %TYPE(xpm); - free(xpm); + delete [] xpm; </template> <template name="qmatrix_map"> @@ -80,8 +47,9 @@ </template> <template name="qimage_buffer_constructor"> + Py_INCREF(%PYARG_1); auto ptr = reinterpret_cast<uchar*>(Shiboken::Buffer::getPointer(%PYARG_1)); - %0 = new %TYPE(ptr, %ARGS); + %0 = new %TYPE(ptr, %ARGS, imageDecrefDataHandler, %PYARG_1); </template> <template name="qcolor_repr"> @@ -125,21 +93,12 @@ } </template> - <template name="qkeysequence_repr"> - QString result; - QDebug debug(&result); - debug.noquote(); - debug.nospace(); - debug << (*%CPPSELF); - %PYARG_0 = Shiboken::String::fromCString(result.toUtf8().constData()); - </template> - <template name="validator_conversionrule"> QValidator::State %out; if (PySequence_Check(%PYARG_0)) { Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_0, 0)); - int size = PySequence_Fast_GET_SIZE(seq.object()); + const Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object()); if (size > 1) { if (%ISCONVERTIBLE[QString](PySequence_Fast_GET_ITEM(seq.object(), 1))) @@ -171,7 +130,7 @@ </template> <template name="qpainter_drawlist"> - %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size()); + %CPPSELF.%FUNCTION_NAME(%1.constData(), %1.size()); </template> <template name="inplace_add"> @@ -203,7 +162,7 @@ <template name="repr_code_matrix"> QByteArray format(Py_TYPE(%PYSELF)->tp_name); - format += QByteArray("(("); + format += QByteArrayLiteral("(("); QList< %MATRIX_TYPE > cppArgs; %MATRIX_TYPE data[%MATRIX_SIZE]; |