media-gfx/freecad: backport various qt6 fixes

enable py3.12 for qt6 builds

Bug: https://bugs.gentoo.org/933439
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
This commit is contained in:
Andrew Ammerlaan
2024-06-03 16:50:21 +02:00
parent 0b838d2161
commit 08ebd7d12c
5 changed files with 380 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
From ccaee18917432fd02e4371a7847bdfaf0692edd1 Mon Sep 17 00:00:00 2001
From: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Date: Sun, 19 May 2024 23:23:45 -0300
Subject: [PATCH] Gui: Fix NaviCube for Qt6
---
src/Gui/NaviCube.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp
index 2d164f196b3c..9e3a62d66c81 100644
--- a/src/Gui/NaviCube.cpp
+++ b/src/Gui/NaviCube.cpp
@@ -926,6 +926,7 @@ NaviCubeImplementation::PickId NaviCubeImplementation::pickFace(short x, short y
GLubyte pixels[4] = {0};
if (m_PickingFramebuffer && std::abs(x) <= m_CubeWidgetSize / 2 &&
std::abs(y) <= m_CubeWidgetSize / 2) {
+ static_cast<QtGLWidget*>(m_View3DInventorViewer->viewport())->makeCurrent();
m_PickingFramebuffer->bind();
glViewport(0, 0, m_CubeWidgetSize * 2, m_CubeWidgetSize * 2);
@@ -936,6 +937,7 @@ NaviCubeImplementation::PickId NaviCubeImplementation::pickFace(short x, short y
glReadPixels(2 * x + m_CubeWidgetSize, 2 * y + m_CubeWidgetSize, 1, 1,
GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
m_PickingFramebuffer->release();
+ static_cast<QtGLWidget*>(m_View3DInventorViewer->viewport())->doneCurrent();
}
return pixels[3] == 255 ? static_cast<PickId>(pixels[0]) : PickId::None;
}

View File

@@ -0,0 +1,186 @@
From 6043c90462e85fbf15e30ea4c7da7d9a22d570f2 Mon Sep 17 00:00:00 2001
From: wmayer <wmayer@users.sourceforge.net>
Date: Wed, 7 Feb 2024 15:25:13 +0100
Subject: [PATCH] Py3.12: harmonize with upstream of PyCXX
---
src/CXX/IndirectPythonInterface.cxx | 36 +++++++++++++++------
src/CXX/Python3/IndirectPythonInterface.hxx | 6 ++--
src/CXX/Python3/cxx_extensions.cxx | 2 +-
src/CXX/Python3/cxxextensions.c | 10 ++++++
src/CXX/Version.hxx | 2 +-
5 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/src/CXX/IndirectPythonInterface.cxx b/src/CXX/IndirectPythonInterface.cxx
index 3d810cea88a5..fc9e45cbd64f 100644
--- a/src/CXX/IndirectPythonInterface.cxx
+++ b/src/CXX/IndirectPythonInterface.cxx
@@ -122,17 +122,21 @@ static PyTypeObject *ptr__Bytes_Type = NULL;
# endif
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+# if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
static int *ptr_Py_DebugFlag = NULL;
static int *ptr_Py_InteractiveFlag = NULL;
static int *ptr_Py_OptimizeFlag = NULL;
static int *ptr_Py_NoSiteFlag = NULL;
static int *ptr_Py_VerboseFlag = NULL;
+# endif
-# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
static const char **ptr__Py_PackageContext = NULL;
-# else
+# else
static char **ptr__Py_PackageContext = NULL;
-# endif
+# endif
+# endif
# endif
# ifdef Py_REF_DEBUG
@@ -242,17 +246,21 @@ bool InitialisePythonIndirectInterface()
ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
# endif
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+# if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
+# endif
-# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
ptr__Py_PackageContext = GetConstCharPointer_as_ConstCharPointerPointer( "_Py_PackageContext" );
-# else
+# else
ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
-# endif
+# endif
+# endif
# endif
# define PYCXX_STANDARD_EXCEPTION( eclass, bclass )
@@ -397,17 +405,21 @@ PYCXX_EXPORT PyTypeObject *_Bytes_Type() { return ptr__Bytes_Type; }
// wrap the Python Flag variables
//
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+# if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
PYCXX_EXPORT int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
PYCXX_EXPORT int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
PYCXX_EXPORT int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
PYCXX_EXPORT int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
PYCXX_EXPORT int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
+# endif
# endif
-# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
PYCXX_EXPORT const char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
-# else
+# else
PYCXX_EXPORT char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
+# endif
# endif
# if 0
@@ -518,15 +530,19 @@ PYCXX_EXPORT PyTypeObject *_Bytes_Type() { return &PyBytes_Type; }
// wrap flags
//
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+# if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
PYCXX_EXPORT int &_Py_DebugFlag() { return Py_DebugFlag; }
PYCXX_EXPORT int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
PYCXX_EXPORT int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
PYCXX_EXPORT int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
PYCXX_EXPORT int &_Py_VerboseFlag() { return Py_VerboseFlag; }
-# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# endif
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
PYCXX_EXPORT const char *__Py_PackageContext() { return _Py_PackageContext; }
-# else
+# else
PYCXX_EXPORT char *__Py_PackageContext() { return _Py_PackageContext; }
+# endif
# endif
# endif
diff --git a/src/CXX/Python3/IndirectPythonInterface.hxx b/src/CXX/Python3/IndirectPythonInterface.hxx
index bf2c15c53f9a..eb4ae4fe63b9 100644
--- a/src/CXX/Python3/IndirectPythonInterface.hxx
+++ b/src/CXX/Python3/IndirectPythonInterface.hxx
@@ -149,10 +149,12 @@ PYCXX_EXPORT int &_Py_NoSiteFlag();
PYCXX_EXPORT int &_Py_TabcheckFlag();
PYCXX_EXPORT int &_Py_VerboseFlag();
-# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
PYCXX_EXPORT const char *__Py_PackageContext();
-# else
+# else
PYCXX_EXPORT char *__Py_PackageContext();
+# endif
# endif
# endif
diff --git a/src/CXX/Python3/cxx_extensions.cxx b/src/CXX/Python3/cxx_extensions.cxx
index 7371810be4a9..e6eefdafea17 100644
--- a/src/CXX/Python3/cxx_extensions.cxx
+++ b/src/CXX/Python3/cxx_extensions.cxx
@@ -152,7 +152,7 @@ PyMethodDef *MethodTable::table()
//================================================================================
ExtensionModuleBase::ExtensionModuleBase( const char *name )
: m_module_name( name )
-#if defined( Py_LIMITED_API )
+#if defined( Py_LIMITED_API ) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 12)
, m_full_module_name( m_module_name )
#else
, m_full_module_name( __Py_PackageContext() != NULL ? std::string( __Py_PackageContext() ) : m_module_name )
diff --git a/src/CXX/Python3/cxxextensions.c b/src/CXX/Python3/cxxextensions.c
index 3b0f8ef7c588..afb9313ad0a8 100644
--- a/src/CXX/Python3/cxxextensions.c
+++ b/src/CXX/Python3/cxxextensions.c
@@ -42,6 +42,14 @@ extern "C"
{
#endif
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13
+PyObject py_object_initializer =
+ {
+ { 1 },
+ NULL // type must be init'ed by user
+ };
+
+#else
PyObject py_object_initializer =
{
_PyObject_EXTRA_INIT
@@ -49,6 +57,8 @@ PyObject py_object_initializer =
NULL // type must be init'ed by user
};
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/CXX/Version.hxx b/src/CXX/Version.hxx
index e6069aad335e..59fe3c203b86 100644
--- a/src/CXX/Version.hxx
+++ b/src/CXX/Version.hxx
@@ -40,7 +40,7 @@
#define PYCXX_VERSION_MAJOR 7
#define PYCXX_VERSION_MINOR 1
-#define PYCXX_VERSION_PATCH 7
+#define PYCXX_VERSION_PATCH 9
#define PYCXX_MAKEVERSION( major, minor, patch ) ((major<<16)|(minor<<8)|(patch))
#define PYCXX_VERSION PYCXX_MAKEVERSION( PYCXX_VERSION_MAJOR, PYCXX_VERSION_MINOR, PYCXX_VERSION_PATCH )
#endif

View File

@@ -0,0 +1,148 @@
From ac9a88c2c59a2d2002a7740a1597a05c819220e0 Mon Sep 17 00:00:00 2001
From: wmayer <wmayer@users.sourceforge.net>
Date: Sat, 20 Apr 2024 14:02:38 +0200
Subject: [PATCH] PySide6: Fixes #13533: QSvgWidget is not a child of QtSvg in
PySide6
* Create a compatibility module QtSvgWidgets.py to handle PySide2 & PySide6
* In the Arch and Material modules use the QtSvgWidgets module
* Since Qt6 the method QFont.setWeight() doesn't accept an int any more but requires an enum. Since the call of QFont.setBold(True) sets
a weight of 75 the extra calls of QFont.setWeight(75) can be safely removed
---
cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake | 3 +++
src/Mod/Arch/ArchPrecast.py | 8 ++++----
src/Mod/Arch/ArchWindow.py | 4 ++--
src/Mod/Arch/importIFClegacy.py | 1 -
src/Mod/Draft/DraftGui.py | 1 -
src/Mod/Material/MaterialEditor.py | 6 +++---
6 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake
index 0569c1fde9f2..fa872e287b59 100644
--- a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake
+++ b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake
@@ -91,9 +91,12 @@ macro(SetupShibokenAndPyside)
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtWidgets.py "from PySide${PYSIDE_MAJOR_VERSION}.QtWidgets import *\n")
if(PYSIDE_MAJOR_VERSION LESS 6)
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtWebEngineWidgets.py "from PySide${PYSIDE_MAJOR_VERSION}.QtWebEngineWidgets import *\n")
+ file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvgWidgets.py "from PySide${PYSIDE_MAJOR_VERSION}.QtSvg import QGraphicsSvgItem\n"
+ "from PySide${PYSIDE_MAJOR_VERSION}.QtSvg import QSvgWidget\n")
else()
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtWebEngineWidgets.py "from PySide${PYSIDE_MAJOR_VERSION}.QtWebEngineWidgets import *\n"
"from PySide${PYSIDE_MAJOR_VERSION}.QtWebEngineCore import QWebEnginePage\n")
+ file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvgWidgets.py "from PySide${PYSIDE_MAJOR_VERSION}.QtSvgWidgets import *\n")
endif()
endif()
diff --git a/src/Mod/Arch/ArchPrecast.py b/src/Mod/Arch/ArchPrecast.py
index 7bb929b10e34..2f482902c1ce 100644
--- a/src/Mod/Arch/ArchPrecast.py
+++ b/src/Mod/Arch/ArchPrecast.py
@@ -777,14 +777,14 @@ class _PrecastTaskPanel:
def __init__(self):
import FreeCADGui
- from PySide import QtCore,QtGui,QtSvg
+ from PySide import QtCore,QtGui,QtSvgWidgets
self.form = QtGui.QWidget()
self.grid = QtGui.QGridLayout(self.form)
self.PrecastTypes = ["Beam","I-Beam","Pillar","Panel","Slab","Stairs"]
self.SlabTypes = ["Champagne","Hat"]
# image display
- self.preview = QtSvg.QSvgWidget(":/ui/ParametersBeam.svg")
+ self.preview = QtSvgWidgets.QSvgWidget(":/ui/ParametersBeam.svg")
self.preview.setMaximumWidth(200)
self.preview.setMinimumHeight(120)
self.grid.addWidget(self.preview,0,0,1,2)
@@ -1263,7 +1263,7 @@ class _DentsTaskPanel:
def __init__(self):
import FreeCADGui
- from PySide import QtCore,QtGui,QtSvg
+ from PySide import QtCore,QtGui,QtSvgWidgets
self.form = QtGui.QWidget()
self.grid = QtGui.QGridLayout(self.form)
self.Rotations = ["N","S","E","O"]
@@ -1282,7 +1282,7 @@ def __init__(self):
self.grid.addWidget(self.buttonRemove,2,1,1,1)
# image display
- self.preview = QtSvg.QSvgWidget(":/ui/ParametersDent.svg")
+ self.preview = QtSvgWidgets.QSvgWidget(":/ui/ParametersDent.svg")
self.preview.setMaximumWidth(200)
self.preview.setMinimumHeight(120)
self.grid.addWidget(self.preview,3,0,1,2)
diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py
index f3c11c5e9c7a..dc9c84f9a8bf 100644
--- a/src/Mod/Arch/ArchWindow.py
+++ b/src/Mod/Arch/ArchWindow.py
@@ -34,7 +34,7 @@
if FreeCAD.GuiUp:
import FreeCADGui
- from PySide import QtCore, QtGui, QtSvg
+ from PySide import QtCore, QtGui, QtSvgWidgets
from draftutils.translate import translate
from PySide.QtCore import QT_TRANSLATE_NOOP
import draftguitools.gui_trackers as DraftTrackers
@@ -426,7 +426,7 @@ def taskbox(self):
self.pic.hide()
# SVG display
- self.im = QtSvg.QSvgWidget(":/ui/ParametersWindowFixed.svg")
+ self.im = QtSvgWidgets.QSvgWidget(":/ui/ParametersWindowFixed.svg")
self.im.setMaximumWidth(200)
self.im.setMinimumHeight(120)
grid.addWidget(self.im,4,0,1,2)
diff --git a/src/Mod/Arch/importIFClegacy.py b/src/Mod/Arch/importIFClegacy.py
index 037e889ce5b9..256b29056b33 100644
--- a/src/Mod/Arch/importIFClegacy.py
+++ b/src/Mod/Arch/importIFClegacy.py
@@ -1795,7 +1795,6 @@ def explorer(filename,schema="IFC2X3_TC1.exp"):
tree.headerItem().setText(1, "")
tree.headerItem().setText(2, "Item and Properties")
bold = QtGui.QFont()
- bold.setWeight(75)
bold.setBold(True)
#print(ifc.Entities)
diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py
index c6e8584f4a71..2471bb66c61a 100644
--- a/src/Mod/Draft/DraftGui.py
+++ b/src/Mod/Draft/DraftGui.py
@@ -312,7 +312,6 @@ def setupToolBar(self,task=False):
self.promptlabel = self._label("promptlabel", self.layout, hide=task)
self.cmdlabel = self._label("cmdlabel", self.layout, hide=task)
boldtxt = QtGui.QFont()
- boldtxt.setWeight(75)
boldtxt.setBold(True)
self.cmdlabel.setFont(boldtxt)
diff --git a/src/Mod/Material/MaterialEditor.py b/src/Mod/Material/MaterialEditor.py
index cbcbde924609..28dbe83bc026 100644
--- a/src/Mod/Material/MaterialEditor.py
+++ b/src/Mod/Material/MaterialEditor.py
@@ -27,7 +27,7 @@
import os
from pathlib import PurePath
import sys
-from PySide import QtCore, QtGui, QtSvg
+from PySide import QtCore, QtGui, QtSvgWidgets
import FreeCAD
import FreeCADGui
@@ -92,11 +92,11 @@ def __init__(self, obj=None, prop=None, material=None, card_path="", category="S
treeView = widget.treeView
# create preview svg slots
- self.widget.PreviewRender = QtSvg.QSvgWidget(self.iconPath + "preview-rendered.svg")
+ self.widget.PreviewRender = QtSvgWidgets.QSvgWidget(self.iconPath + "preview-rendered.svg")
self.widget.PreviewRender.setMaximumWidth(64)
self.widget.PreviewRender.setMinimumHeight(64)
self.widget.topLayout.addWidget(self.widget.PreviewRender)
- self.widget.PreviewVector = QtSvg.QSvgWidget(self.iconPath + "preview-vector.svg")
+ self.widget.PreviewVector = QtSvgWidgets.QSvgWidget(self.iconPath + "preview-vector.svg")
self.widget.PreviewVector.setMaximumWidth(64)
self.widget.PreviewVector.setMinimumHeight(64)
self.widget.topLayout.addWidget(self.widget.PreviewVector)

View File

@@ -3,7 +3,7 @@
EAPI=8
PYTHON_COMPAT=( python3_{10..11} )
PYTHON_COMPAT=( python3_{10..12} )
inherit check-reqs cmake flag-o-matic optfeature python-single-r1 qmake-utils xdg
@@ -93,8 +93,8 @@ RDEPEND="
$(python_gen_cond_dep '
dev-python/matplotlib[${PYTHON_USEDEP}]
>=dev-python/pivy-0.6.5[${PYTHON_USEDEP}]
dev-python/pyside2[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken2[${PYTHON_USEDEP}]
dev-python/pyside2:=[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken2:=[${PYTHON_USEDEP}]
' python3_{10..11} )
)
qt6? (
@@ -109,8 +109,8 @@ RDEPEND="
$(python_gen_cond_dep '
dev-python/matplotlib[${PYTHON_USEDEP}]
>=dev-python/pivy-0.6.5[${PYTHON_USEDEP}]
dev-python/pyside6[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken6[${PYTHON_USEDEP}]
dev-python/pyside6:=[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken6:=[${PYTHON_USEDEP}]
' )
)
)
@@ -159,7 +159,9 @@ REQUIRED_USE="
designer? ( gui )
inspection? ( points )
path? ( robot )
python_single_target_python3_12? ( gui? ( qt6 ) )
"
# There is no py3.12 support planned for pyside2
PATCHES=(
"${FILESDIR}"/${PN}-0.21.0-0001-Gentoo-specific-disable-ccache-usage.patch
@@ -191,6 +193,12 @@ src_prepare() {
eapply "${FILESDIR}/${PN}-0.21.2-shiboken-6.7.0.patch"
fi
if use qt6; then
eapply "${FILESDIR}/${PN}-0.21.2-navcube-qt6.patch"
eapply "${FILESDIR}/${PN}-0.21.2-qtsvg-qt6.patch"
eapply "${FILESDIR}/${PN}-0.21.2-py312-qt6.patch"
fi
cmake_src_prepare
}

View File

@@ -94,8 +94,8 @@ RDEPEND="
$(python_gen_cond_dep '
dev-python/matplotlib[${PYTHON_USEDEP}]
>=dev-python/pivy-0.6.5[${PYTHON_USEDEP}]
dev-python/pyside2[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken2[${PYTHON_USEDEP}]
dev-python/pyside2:=[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken2:=[${PYTHON_USEDEP}]
' python3_{10..11} )
)
qt6? (
@@ -109,8 +109,8 @@ RDEPEND="
$(python_gen_cond_dep '
dev-python/matplotlib[${PYTHON_USEDEP}]
>=dev-python/pivy-0.6.5[${PYTHON_USEDEP}]
dev-python/pyside6[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken6[${PYTHON_USEDEP}]
dev-python/pyside6:=[gui,svg,webchannel,webengine,${PYTHON_USEDEP}]
dev-python/shiboken6:=[${PYTHON_USEDEP}]
' )
)
)