From 0a478f1f631f701a008cf4552ec26cc7074e4f63 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 31 Jan 2018 15:49:55 +0100 Subject: Fix QSsl classes to be picked up on Linux The compile tests that checked for QSsl classes silently failed because of two different reasons: 1) If Qt was compiled with -fPIC, but the tests weren't, we hit a compilation error. Solution is to compile with -fPIC if necessary. 2) For some reason when linking, the linker can't find the qt version tag symbol. Solution is to simply not use the version tag. Task-number: PYSIDE-599 Change-Id: If8a6ea38b45091bcaced6179a71195d25589ef18 Reviewed-by: Friedemann Kleint --- sources/pyside2/cmake/Macros/PySideModules.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sources/pyside2') diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake index 77653925e..0bef89b0c 100644 --- a/sources/pyside2/cmake/Macros/PySideModules.cmake +++ b/sources/pyside2/cmake/Macros/PySideModules.cmake @@ -155,10 +155,19 @@ macro(check_qt_class module class optional_source_files dropped_entries) "${NAMESPACE_USE}\n" "int main() { sizeof(${class}); }\n" ) + + # Because Qt is built with -fPIC (by default), the compile tests also have to have that. + get_property(ADDITIONAL_FLAGS TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS) + + # Don't add version tagging, because for some reason linker fails with: + # (.qtversion[qt_version_tag]+0x0): undefined reference to `qt_version_tag' + set(ADDITIONAL_FLAGS "${ADDITIONAL_FLAGS} -DQT_NO_VERSION_TAGGING") + try_compile(Q_WORKS ${CMAKE_BINARY_DIR} ${SRC_FILE} CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${QT_INCLUDE_DIR};${Qt5${_module_no_qt_prefix}_INCLUDE_DIRS}" + "-DCOMPILE_DEFINITIONS:STRING=${ADDITIONAL_FLAGS}" OUTPUT_VARIABLE OUTPUT) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCheckQtClassTest.log ${OUTPUT}) -- cgit v1.2.3 From a18e81dd1311811eb1227cf46d253ae647a9fbdd Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Fri, 26 Jan 2018 09:47:48 +0100 Subject: Fix QTabWidget.clear to avoid double obj removal Replacing shiboken call setParent with releaseOwnership so Python will not delete the underlying C++ object. A test case is provided to check that the error is not happening. Task-number: PYSIDE-213 Change-Id: Ic0f383c3d93b905885f76788d32d62ba37ed9d2f Reviewed-by: Alexandru Croitor --- .../QtWidgets/typesystem_widgets_common.xml | 7 ++- sources/pyside2/tests/QtWidgets/CMakeLists.txt | 1 + .../tests/QtWidgets/qtabwidgetclear_test.py | 63 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 sources/pyside2/tests/QtWidgets/qtabwidgetclear_test.py (limited to 'sources/pyside2') diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index 9d3e70be2..1663e4f4e 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -2507,10 +2507,13 @@ + Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); for (int i = 0; i < %CPPSELF.count(); i++) { QWidget* widget = %CPPSELF.widget(i); - Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget)); - Shiboken::Object::setParent(0, pyWidget); + if (bm.hasWrapper(widget)) { + Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget)); + Shiboken::Object::releaseOwnership(pyWidget); + } } %CPPSELF.%FUNCTION_NAME(); diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index 3c31b1d7d..46a07c9a3 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -117,6 +117,7 @@ PYSIDE_TEST(qstring_qkeysequence_test.py) PYSIDE_TEST(qstyle_test.py) PYSIDE_TEST(qtableview_test.py) PYSIDE_TEST(qtabwidget_test.py) +PYSIDE_TEST(qtabwidgetclear_test.py) PYSIDE_TEST(qtextedit_test.py) PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtoolbar_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qtabwidgetclear_test.py b/sources/pyside2/tests/QtWidgets/qtabwidgetclear_test.py new file mode 100644 index 000000000..8e9b36fab --- /dev/null +++ b/sources/pyside2/tests/QtWidgets/qtabwidgetclear_test.py @@ -0,0 +1,63 @@ +############################################################################# +## +## 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 QMainWindow, QTabWidget, QTextEdit, QSplitter +from helper import UsesQApplication + +class TabWidgetClear(QMainWindow): + def __init__(self): + QMainWindow.__init__(self) + self.tabWidget = QTabWidget(self) + self.setCentralWidget(self.tabWidget) + self.editBox = QTextEdit(self) + self.tabWidget.addTab(self.getSplitter(), 'Test') + + def getSplitter(self): + splitter = QSplitter() + splitter.addWidget(self.editBox) + return splitter + + def toggle(self): + self.tabWidget.clear() + self.getSplitter() + +class TestTabWidgetClear(UsesQApplication): + + def testClear(self): + self.window = TabWidgetClear() + self.window.show() + try: + self.window.toggle() + except RuntimeError as e: + # This should never happened, PYSIDE-213 + raise e + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3