From 1e73654dcd5d27c8441adf9d72f2ece8b47d17ab Mon Sep 17 00:00:00 2001 From: Aaron Colwell <300262+acolwell@users.noreply.github.com> Date: Sat, 22 Apr 2023 11:53:30 -0700 Subject: [PATCH] Fixes to get Qt5 working on Windows. (#872) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes to get Qt5 working on Windows. * FileTypeMainWindow_win.cpp: avoid double open curly braces --------- Co-authored-by: Frédéric Devernay --- Gui/FileTypeMainWindow_win.cpp | 37 ++++++++--- Gui/FileTypeMainWindow_win.h | 6 +- Gui/Pyside_Gui_Python.h | 3 + Gui/PythonPanels.h | 2 + Gui/TaskBar.cpp | 7 ++- Gui/TaskBar.h | 2 +- global.pri | 13 ++-- tools/jenkins/build-Windows-installer.sh | 35 ++++++++--- tools/jenkins/build-natron.sh | 8 ++- tools/jenkins/genDllVersions.sh | 78 +++++++++++++++++------- 10 files changed, 139 insertions(+), 52 deletions(-) diff --git a/Gui/FileTypeMainWindow_win.cpp b/Gui/FileTypeMainWindow_win.cpp index 49b98aabf6..2edd528130 100644 --- a/Gui/FileTypeMainWindow_win.cpp +++ b/Gui/FileTypeMainWindow_win.cpp @@ -87,27 +87,50 @@ DocumentWindow::~DocumentWindow() // —— public slots —————————————————————————— // —— protected slots ————————————————————————— // —— events ———————————————————————————— +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) bool -DocumentWindow::winEvent(MSG *message, - long *result) +DocumentWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) { - switch (message->message) { + MSG* msg = static_cast(message); + switch (msg->message) { case WM_DDE_INITIATE: - return ddeInitiate(message, result); + return ddeInitiate(msg, result); break; case WM_DDE_EXECUTE: - return ddeExecute(message, result); + return ddeExecute(msg, result); break; case WM_DDE_TERMINATE: - return ddeTerminate(message, result); + return ddeTerminate(msg, result); break; } - return QMainWindow::winEvent(message, result); + return QMainWindow::nativeEvent(eventType, message, result); } +#else +bool +DocumentWindow::winEvent(MSG* msg, long *result) +{ + switch (msg->message) { + case WM_DDE_INITIATE: + + return ddeInitiate(msg, result); + break; + case WM_DDE_EXECUTE: + + return ddeExecute(msg, result); + break; + case WM_DDE_TERMINATE: + + return ddeTerminate(msg, result); + break; + } + + return QMainWindow::winEvent(msg, result); +} +#endif void DocumentWindow::ddeOpenFile(const QString&) diff --git a/Gui/FileTypeMainWindow_win.h b/Gui/FileTypeMainWindow_win.h index c5a691a9ca..d3525e9466 100644 --- a/Gui/FileTypeMainWindow_win.h +++ b/Gui/FileTypeMainWindow_win.h @@ -138,7 +138,11 @@ class DocumentWindow /** * reimpl as DDE events come as windows events and are not translated by Qt. */ - virtual bool winEvent(MSG *message, long *result); + #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result); + #else + virtual bool winEvent(MSG *msg, long *result); + #endif // —— helpers for the file registration —————————————————— /** diff --git a/Gui/Pyside_Gui_Python.h b/Gui/Pyside_Gui_Python.h index afe4cda71c..a6533e9017 100644 --- a/Gui/Pyside_Gui_Python.h +++ b/Gui/Pyside_Gui_Python.h @@ -37,6 +37,9 @@ #include #endif +#include +#include + #include //Global diff --git a/Gui/PythonPanels.h b/Gui/PythonPanels.h index cc88316656..2a688fca27 100644 --- a/Gui/PythonPanels.h +++ b/Gui/PythonPanels.h @@ -30,6 +30,8 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) +// Include order matters here to keep shiboken happy. +#include #include CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) diff --git a/Gui/TaskBar.cpp b/Gui/TaskBar.cpp index 94c22b9d80..cb3bcff1cc 100644 --- a/Gui/TaskBar.cpp +++ b/Gui/TaskBar.cpp @@ -39,7 +39,8 @@ TaskBar::TaskBar(QWidget *parent) , _state(NoProgress) { #ifdef Q_OS_WIN - _wid = parent->window()->winId(); + // QT4 typedefs WId as an HWND, but QT5 typdefs it as a quintptr, so a cast is needed. + _hwnd = reinterpret_cast(parent->window()->winId()); CoInitialize(NULL); HRESULT hres = CoCreateInstance(CLSID_TaskbarList, NULL, @@ -112,7 +113,7 @@ TaskBar::setProgressValue(double value) if (!_wtask) { return; } - if (_wtask->SetProgressValue(_wid, currentVal, totalVal) == S_OK) { + if (_wtask->SetProgressValue(_hwnd, currentVal, totalVal) == S_OK) { _val = value; } #elif defined(Q_OS_DARWIN) @@ -153,7 +154,7 @@ TaskBar::setProgressState(TaskBar::ProgressState state) flag = TBPF_NORMAL; break; } - if (_wtask->SetProgressState(_wid, flag) == S_OK) { + if (_wtask->SetProgressState(_hwnd, flag) == S_OK) { _state = state; } #elif defined(Q_OS_DARWIN) diff --git a/Gui/TaskBar.h b/Gui/TaskBar.h index f647c8feb3..64dd102418 100644 --- a/Gui/TaskBar.h +++ b/Gui/TaskBar.h @@ -71,7 +71,7 @@ public Q_SLOTS: #ifdef Q_OS_WIN ITaskbarList3 *_wtask; - WId _wid; + HWND _hwnd; #elif defined(Q_OS_DARWIN) TaskBarMac *_mtask; #endif diff --git a/global.pri b/global.pri index 2ef5448d8a..4290f314b4 100644 --- a/global.pri +++ b/global.pri @@ -419,11 +419,14 @@ win32-g++ { expat: PKGCONFIG += expat cairo: PKGCONFIG += cairo fontconfig equals(QT_MAJOR_VERSION, 5) { - shiboken: INCLUDEPATH += $$PYTHON_SITE_PACKAGES/PySide2/include/shiboken2 - pyside: INCLUDEPATH += $$PYTHON_SITE_PACKAGES/PySide2/include/PySide2 - pyside: INCLUDEPATH += $$PYTHON_SITE_PACKAGES/PySide2/include/PySide2/QtCore - pyside: INCLUDEPATH += $$PYTHON_SITE_PACKAGES/PySide2/include/PySide2/QtGui - pyside: INCLUDEPATH += $$PYTHON_SITE_PACKAGES/PySide2/include/PySide2/QtWidgets + shiboken: INCLUDEPATH += $$system(pkg-config --variable=includedir shiboken2) + PYSIDE_INCLUDEDIR = $$system(pkg-config --variable=includedir pyside2) + pyside: INCLUDEPATH += $$PYSIDE_INCLUDEDIR + pyside: INCLUDEPATH += $$PYSIDE_INCLUDEDIR/QtCore + pyside: INCLUDEPATH += $$PYSIDE_INCLUDEDIR/QtGui + pyside: INCLUDEPATH += $$PYSIDE_INCLUDEDIR/QtWidgets + shiboken: PKGCONFIG += shiboken2 + pyside: PKGCONFIG += pyside2 } equals(QT_MAJOR_VERSION, 4) { shiboken: PKGCONFIG += shiboken-py$$PYV diff --git a/tools/jenkins/build-Windows-installer.sh b/tools/jenkins/build-Windows-installer.sh index f49834c688..3fcba27459 100755 --- a/tools/jenkins/build-Windows-installer.sh +++ b/tools/jenkins/build-Windows-installer.sh @@ -41,7 +41,7 @@ popd () { } # Generate dll versions with dlls on the system -env BITS="$BITS" PYVER="$PYVER" PYV="${PYV}" NATRON_LICENSE="$NATRON_LICENSE" ./genDllVersions.sh +env BITS="$BITS" PYVER="$PYVER" PYV="${PYV}" QT_VERSION_MAJOR="${QT_VERSION_MAJOR}" NATRON_LICENSE="$NATRON_LICENSE" ./genDllVersions.sh source dllVersions.sh @@ -365,19 +365,21 @@ for location in "${COPY_LOCATIONS[@]}"; do #cp -a "$SDK_HOME/etc/fonts"/* "$location/Resources/etc/fonts" cp -a "${TMP_BINARIES_PATH}/Resources/etc/fonts"/* "$location/Resources/etc/fonts/" cp -a "$SDK_HOME/share/poppler" "$location/Resources/" - cp -a "$SDK_HOME/share/qt4/plugins"/* "$location/bin/" - rm -f "$location/bin"/*/*d4.dll || true + cp -a "$SDK_HOME/share/qt${QT_VERSION_MAJOR}/plugins"/* "$location/bin/" for depend in "${NATRON_DLL[@]}"; do cp "$depend" "$location/bin/" done #Copy Qt dlls (required for all PySide modules to work correctly) - cp "$SDK_HOME/bin"/Qt*4.dll "$location/bin/" - + if [ "${QT_VERSION_MAJOR}" = 4 ]; then + cp "$SDK_HOME/bin"/Qt*4.dll "$location/bin/" + # Ignore debug dlls of Qt + rm "$location/bin"/*d4.dll || true + else + cp "$SDK_HOME/bin"/Qt${QT_VERSION_MAJOR}*.dll "$location/bin/" + fi - # Ignore debug dlls of Qt - rm "$location/bin"/*d4.dll || true rm "$location/bin/sqldrivers"/{*mysql*,*psql*} || true if [ "$COMPILE_TYPE" != "debug" ]; then @@ -394,7 +396,15 @@ done mkdir -p "${TMP_PORTABLE_DIR}/Plugins" cp -a "$SDK_HOME/lib/python${PYVER}" "${TMP_PORTABLE_DIR}/lib/" -mv "${TMP_PORTABLE_DIR}/lib/python${PYVER}/site-packages/PySide" "${TMP_PORTABLE_DIR}/Plugins/" + +if [[ ${QT_VERSION_MAJOR} -ge 5 ]]; then + PYSIDE_PLUGIN_PATH="${TMP_PORTABLE_DIR}/Plugins/PySide2" + mv "${TMP_PORTABLE_DIR}/lib/python${PYVER}/site-packages/PySide2" "${TMP_PORTABLE_DIR}/lib/python${PYVER}/site-packages/shiboken2" "${TMP_PORTABLE_DIR}/Plugins" +else + PYSIDE_PLUGIN_PATH="${TMP_PORTABLE_DIR}/Plugins/PySide" + mv "${TMP_PORTABLE_DIR}/lib/python${PYVER}/site-packages/PySide" "${TMP_PORTABLE_DIR}/Plugins" +fi + rm -rf "${TMP_PORTABLE_DIR}/lib/python${PYVER}"/{test,config,config-"${PYVER}"m} ( cd "${TMP_PORTABLE_DIR}/lib/python${PYVER}/site-packages"; @@ -414,13 +424,17 @@ find "${PYDIR}" -type f -name '*.pyo' -exec rm {} \; ) if [ "$COMPILE_TYPE" != "debug" ]; then -for dir in "${TMP_PORTABLE_DIR}/Plugins/PySide" "${TMP_PORTABLE_DIR}/lib/python${PYVER:-}"; do +for dir in "${PYSIDE_PLUGIN_PATH}" "${TMP_PORTABLE_DIR}/lib/python${PYVER:-}"; do echo "*** stripping binaries in $dir" find "$dir" -type f \( -iname '*.exe' -o -iname '*.dll' -o -iname '*.pyd' -o -iname '*.ofx' \) -exec strip -s {} \; echo "*** stripping binaries in $dir... done!" done fi +if [[ ${QT_VERSION_MAJOR} -ge 5 ]]; then + USE_QT5=1 +fi + # python zip if [ "${USE_QT5:-}" != 1 ]; then rm -rf "$PYDIR"/site-packages/shiboken2* "$PYDIR"/site-packages/PySide2 || true @@ -466,7 +480,8 @@ fi cp -r "$PYDIR" "$DLLS_PACKAGE_PATH/data/lib/" cp "${TMP_PORTABLE_DIR}"/lib/python*.zip "${DLLS_PACKAGE_PATH}/data/lib/" mkdir -p "${DLLS_PACKAGE_PATH}/data/Plugins" -cp -a "${TMP_PORTABLE_DIR}/Plugins/PySide" "${DLLS_PACKAGE_PATH}/data/Plugins/" + +cp -a "${PYSIDE_PLUGIN_PATH}" "${DLLS_PACKAGE_PATH}/data/Plugins/" # Configure the package date using the most recent DLL modification date CLIBS_VERSION="00000000000000" diff --git a/tools/jenkins/build-natron.sh b/tools/jenkins/build-natron.sh index 4fa280e0d1..c1b4a7d0a7 100755 --- a/tools/jenkins/build-natron.sh +++ b/tools/jenkins/build-natron.sh @@ -170,10 +170,12 @@ if [ "$QT_VERSION_MAJOR" = 5 ]; then esac rm Engine/Qt${QT_VERSION_MAJOR}/NatronEngine/* Gui/Qt${QT_VERSION_MAJOR}/NatronGui/* || true - # ${PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/include - shiboken2-${PYVER} --avoid-protected-hack --enable-pyside-extensions --include-paths=.:Engine:Global:libs/OpenFX/include:${SDK_HOME}/include:${QTDIR}/include:${PYTHON_HOME}/include/python${PYVER}:${PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/include --typesystem-paths=${PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/typesystems --output-directory=Engine/Qt${QT_VERSION_MAJOR} Engine/Pyside2_Engine_Python.h Engine/typesystem_engine.xml + UNIX_PYTHON_HOME=`cygpath -u "${PYTHON_HOME}"` + SHIBOKEN_INCLUDE_PATHS=".:./Engine:./Global:libs/OpenFX/include:${UNIX_PYTHON_HOME}/include/python${PYVER}:${UNIX_PYTHON_HOME}/include/PySide2" + SHIBOKEN_TYPESYSTEM_PATHS="${UNIX_PYTHON_HOME}/share/PySide2/typesystems" + shiboken2 --avoid-protected-hack --enable-pyside-extensions --include-paths=${SHIBOKEN_INCLUDE_PATHS} --typesystem-paths=${SHIBOKEN_TYPESYSTEM_PATHS} --output-directory=Engine/Qt${QT_VERSION_MAJOR} Engine/Pyside2_Engine_Python.h Engine/typesystem_engine.xml - shiboken2-${PYVER} --avoid-protected-hack --enable-pyside-extensions --include-paths=.:Engine:Global:libs/OpenFX/include:${SDK_HOME}/include:${QTDIR}/include:${QTDIR}/include/QtWidgets:${PYTHON_HOME}/include/python${PYVER}:${PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/include --typesystem-paths=${PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/typesystems:Engine:Shiboken --output-directory=Gui/Qt${QT_VERSION_MAJOR} Gui/Pyside2_Gui_Python.h Gui/typesystem_natronGui.xml + shiboken2 --avoid-protected-hack --enable-pyside-extensions --include-paths=${SHIBOKEN_INCLUDE_PATHS}:${QTDIR}/include/QtWidgets:${QTDIR}/include/QtCore --typesystem-paths=${SHIBOKEN_TYPESYSTEM_PATHS}:./Engine:./Shiboken --output-directory=Gui/Qt${QT_VERSION_MAJOR} Gui/Pyside2_Gui_Python.h Gui/typesystem_natronGui.xml tools/utils/runPostShiboken2.sh Engine/Qt${QT_VERSION_MAJOR}/NatronEngine natronengine tools/utils/runPostShiboken2.sh Gui/Qt${QT_VERSION_MAJOR}/NatronGui natrongui diff --git a/tools/jenkins/genDllVersions.sh b/tools/jenkins/genDllVersions.sh index 4f8375d755..c2e165a0f6 100755 --- a/tools/jenkins/genDllVersions.sh +++ b/tools/jenkins/genDllVersions.sh @@ -89,26 +89,62 @@ function catDll() { INIT_VAR=1 DLL_VAR_PREFIX="NATRON" BIN_PATH="$SDK_HOME_BIN" -# all Qt libraries are necessary for PySide -catDll Qt3Support4 -catDll QtCLucene4 -catDll QtCore4 -catDll QtDBus4 -catDll QtDeclarative4 -catDll QtDesigner4 -catDll QtDesignerComponents4 -catDll QtGui4 -catDll QtHelp4 -catDll QtMultimedia4 -catDll QtNetwork4 -catDll QtOpenGL4 -catDll QtScript4 -catDll QtScriptTools4 -catDll QtSql4 -catDll QtSvg4 -catDll QtTest4 -catDll QtXml4 -catDll QtXmlPatterns4 +if [ "$QT_VERSION_MAJOR" = "4" ]; then + # all Qt libraries are necessary for PySide + catDll Qt3Support4 + catDll QtCLucene4 + catDll QtCore4 + catDll QtDBus4 + catDll QtDeclarative4 + catDll QtDesigner4 + catDll QtDesignerComponents4 + catDll QtGui4 + catDll QtHelp4 + catDll QtMultimedia4 + catDll QtNetwork4 + catDll QtOpenGL4 + catDll QtScript4 + catDll QtScriptTools4 + catDll QtSql4 + catDll QtSvg4 + catDll QtTest4 + catDll QtXml4 + catDll QtXmlPatterns4 + + catDll phonon4 + catDll libmng- + catDll libpcre- +elif [ "$QT_VERSION_MAJOR" = "5" ]; then + catDll Qt5Concurrent + catDll Qt5Core + catDll Qt5DBus + catDll Qt5Gui + catDll Qt5Network + catDll Qt5OpenGL + catDll Qt5PrintSupport + catDll Qt5Qml + catDll Qt5QmlModels + catDll Qt5QmlWorkerScript + catDll Qt5Quick + catDll Qt5QuickParticles + catDll Qt5QuickShapes + catDll Qt5QuickTest + catDll Qt5QuickWidgets + catDll Qt5Sql + catDll Qt5Test + catDll Qt5Widgets + catDll Qt5Xml + catDll Qt5XmlPatterns + + catDll libdouble-conversion + catDll libicuin + catDll libpcre2-16- + catDll libmd4c +else + echo "Unsupported QT_MAJOR_VERSION" ${QT_VERSION_MAJOR} + exit 1 +fi + catDll fbclient catDll libass- @@ -157,7 +193,6 @@ catDll libjpeg- catDll liblcms2- catDll liblzma- catDll libmfx -catDll libmng- catDll libmodplug- catDll libmp3lame- catDll libnettle- @@ -200,7 +235,6 @@ catDll libwebpdemux- catDll libwebpmux- catDll libwinpthread- catDll libxml2- -catDll phonon4 #catDll SDL2 #catDll SSLEAY32 catDll zlib1