From 1effc5799077de1bd2b840b159c7f28b8a916f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 9 Apr 2023 16:14:54 +0200 Subject: [PATCH 1/2] Fix Python package installation in CMake for tests. --- tests/python/CMakeLists.txt | 4 +++- tests/runner/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 3c4e2dd..8cefd01 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -30,7 +30,9 @@ QT_ROOT=set:${QT_ROOT}" mo2_python_pip_install(python-tests DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pylibs - PACKAGES pytest PyQt6==6.3.0) + PACKAGES pytest + PyQt${QT_MAJOR_VERSION}==${QT_VERSION} + PyQt${QT_MAJOR_VERSION}-Qt${QT_MAJOR_VERSION}==${QT_VERSION}) add_dependencies(python-tests mobase) set_target_properties(python-tests PROPERTIES FOLDER tests/python) diff --git a/tests/runner/CMakeLists.txt b/tests/runner/CMakeLists.txt index 12bf544..42793d8 100644 --- a/tests/runner/CMakeLists.txt +++ b/tests/runner/CMakeLists.txt @@ -19,7 +19,9 @@ target_link_libraries(runner-tests PUBLIC runner) set(PYLIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/pylibs) mo2_python_pip_install(runner-tests DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pylibs - PACKAGES pytest PyQt6==6.3.0) + PACKAGES + PyQt${QT_MAJOR_VERSION}==${QT_VERSION} + PyQt${QT_MAJOR_VERSION}-Qt${QT_MAJOR_VERSION}==${QT_VERSION}) add_dependencies(runner-tests mobase) From 1cdeb081b2fa59c28cea8c9a4261a46646f5d2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 9 Apr 2023 20:41:57 +0200 Subject: [PATCH 2/2] Fix conversion operators for Qt type casters with latest pybind11. --- .../pybind11_qt/details/pybind11_qt_sip.h | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/pybind11-qt/include/pybind11_qt/details/pybind11_qt_sip.h b/src/pybind11-qt/include/pybind11_qt/details/pybind11_qt_sip.h index a2712ca..be2e882 100644 --- a/src/pybind11-qt/include/pybind11_qt/details/pybind11_qt_sip.h +++ b/src/pybind11-qt/include/pybind11_qt/details/pybind11_qt_sip.h @@ -52,16 +52,28 @@ namespace pybind11::detail::qt { } } - template && !is_pointer, int> = 0> - operator T&() + // pybind11 requires operator T&() & and operator T&&() && but here we want to + // use SFINAE with is_pointer so we need to template the operator + // + // having a template operator U&&() does not work since it will not + // deduce the proper return type for QClass&& or QClass& so we have two separate + // overloads, and in each one, U is actually a reference type (lvalue or rvalue) + // + + template , QClass> && + std::is_lvalue_reference_v && !is_pointer, + int> = 0> + operator U() { return value; } - template && !is_pointer, int> = 0> - operator T&&() && + template , QClass> && + std::is_rvalue_reference_v && !is_pointer, + int> = 0> + operator U() && { return std::move(value); }