View Issue Details

IDProjectCategoryView StatusLast Update
0003984PathPatchpublic2021-12-17 05:14
Reportercmt Assigned Towmayer  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.18 
Target Version0.20 
Summary0003984: Creating a Path Job object fails with "PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup'"
DescriptionThis is FreeCAD 0.18.2 on FreeBSD - originally reported on FreeBSD 11, but clearly reproducable on FreeBSD 12 - with a quite recent Qt (5.12.2) and PySide2 stack (5.12.3).

Operations for Paths - like creating a Path Object or starting the Tool Manager fail with errors like

Running the Python command 'Path_Job' failed:
Traceback (most recent call last):
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobCmd.py", line 64, in
Activated
    dialog = PathJobDlg.JobCreate()
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobDlg.py", line 55, in
__init__
    self.dialog.templateGroup.hide()
                                                                                                                                                                                           
'PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup'

This does not happen in the official 0.18.1 AppImage on Linux, but then that AppImage packs a much older Qt version. I stared a little at the code and the GUI definitions, but I'm not really a Qt-developer myself.

Original Report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237987
Steps To Reproduce- open FreeCAD and take any trivial object (like the box from the Path tutorial, or a simple flat piece with a hole, doesn't matter
- switch to the Path workbench
- try to create a new Path Job object ("pj" or mouse click), no new Object but error:

Running the Python command 'Path_Job' failed:
Traceback (most recent call last):
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobCmd.py", line 64, in Activated
    dialog = PathJobDlg.JobCreate()
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobDlg.py", line 55, in __init__
    self.dialog.templateGroup.hide()

'PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup'
Additional InformationOS: FreeBSD 12.0-RELEASE-p3
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.0.18.2
Build type: Release
Python version: 3.6.8
Qt version: 5.12.2
Coin version: 3.1.3
OCC version: 7.3.0
Locale: English/United States (en_US)
TagsFreeBSD
FreeCAD Information

Activities

cmt

2019-05-20 17:13

reporter  

FreeCAD.log (11,876 bytes)   
Msg: FreeCAD 0.18, Libs: 0.18R0.18.2
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

Log: Time = Mon May 20 18:48:58 2019
Log: AppDataSkipVendor = true
Log: AppHomePath = /usr/local/FreeCAD/
Log: AppIcon = freecad
Log: AppTempPath = /tmp/
Log: BinPath = /usr/local/FreeCAD/bin/
Log: BuildRepositoryURL = Unknown
Log: BuildRevision = 0.18.2
Log: BuildRevisionDate = Unknown
Log: BuildVersionMajor = 0
Log: BuildVersionMinor = 18
Log: Console = 0
Log: CopyrightInfo = © Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##


Log: Debug = 0
Log: DocPath = /usr/local/FreeCAD/doc/
Log: ExeName = FreeCAD
Log: ExeVendor = FreeCAD
Log: ExeVersion = 0.18
Log: LoggingFile = 1
Log: LoggingFileName = /home/cmt/.FreeCAD/FreeCAD.log
Log: MaintainerUrl = http://www.freecadweb.org/wiki/Main_Page
Log: PATH = /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/games:/home/cmt/bin
Log: PYTHONPATH = 
Log: PythonSearchPath = /usr/local/bin/../lib/python36.zip:/usr/local/bin/../lib/python3.6:/usr/local/bin/../lib/python3.6:/usr/local/bin/../lib/python3.6/lib-dynload
Log: RunMode = Gui
Log: SplashAlignment = Bottom|Left
Log: SplashInfoColor = #c8c8c8
Log: SplashScreen = freecadsplash
Log: SplashTextColor = #ffffff
Log: StartWorkbench = StartWorkbench
Log: SystemParameter = /home/cmt/.FreeCAD/system.cfg
Log: UserAppData = /home/cmt/.FreeCAD/
Log: UserHomePath = /home/cmt
Log: UserParameter = /home/cmt/.FreeCAD/user.cfg
Log: Verbose = 
Log: Create Application
Log: Run App init script
Log: Init: starting App::FreeCADInit.py
Log: Init:   Searching for modules...
Log: Init:      Initializing /usr/local/FreeCAD/Mod/AddonManager... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Arch... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Complete... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Draft... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Drawing... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Fem... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Idf... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Image... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Import... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Inspection... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Material... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Measure... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Mesh... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/MeshPart... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/OpenSCAD... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Part... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/PartDesign... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Path... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Plot(Init.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Points... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Raytracing... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/ReverseEngineering... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Robot... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Ship(Init.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Show(Init.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Sketcher... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Spreadsheet... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Start... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Surface... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/TechDraw... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Test... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Tux(Init.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Web... done
Log: Using /usr/local/FreeCAD/Mod as module path!
Log: System path after init:
Log:    /usr/local/FreeCAD/bin
Log:    /usr/local/FreeCAD/Mod/AddonManager
Log:    /usr/local/FreeCAD/Mod/Arch
Log:    /usr/local/FreeCAD/Mod/Complete
Log:    /usr/local/FreeCAD/Mod/Draft
Log:    /usr/local/FreeCAD/Mod/Drawing
Log:    /usr/local/FreeCAD/Mod/Fem
Log:    /usr/local/FreeCAD/Mod/Idf
Log:    /usr/local/FreeCAD/Mod/Image
Log:    /usr/local/FreeCAD/Mod/Import
Log:    /usr/local/FreeCAD/Mod/Inspection
Log:    /usr/local/FreeCAD/Mod/Material
Log:    /usr/local/FreeCAD/Mod/Measure
Log:    /usr/local/FreeCAD/Mod/Mesh
Log:    /usr/local/FreeCAD/Mod/MeshPart
Log:    /usr/local/FreeCAD/Mod/OpenSCAD
Log:    /usr/local/FreeCAD/Mod/Part
Log:    /usr/local/FreeCAD/Mod/PartDesign
Log:    /usr/local/FreeCAD/Mod/Path
Log:    /usr/local/FreeCAD/Mod/Plot
Log:    /usr/local/FreeCAD/Mod/Points
Log:    /usr/local/FreeCAD/Mod/Raytracing
Log:    /usr/local/FreeCAD/Mod/ReverseEngineering
Log:    /usr/local/FreeCAD/Mod/Robot
Log:    /usr/local/FreeCAD/Mod/Ship
Log:    /usr/local/FreeCAD/Mod/Show
Log:    /usr/local/FreeCAD/Mod/Sketcher
Log:    /usr/local/FreeCAD/Mod/Spreadsheet
Log:    /usr/local/FreeCAD/Mod/Start
Log:    /usr/local/FreeCAD/Mod/Surface
Log:    /usr/local/FreeCAD/Mod/TechDraw
Log:    /usr/local/FreeCAD/Mod/Test
Log:    /usr/local/FreeCAD/Mod/Tux
Log:    /usr/local/FreeCAD/Mod/Web
Log:    /usr/local/bin
Log:    /usr/local/sbin
Log:    /usr/bin
Log:    /usr/sbin
Log:    /bin
Log:    /sbin
Log:    /usr/games
Log:    /home/cmt/bin
Log: Init: App::FreeCADInit.py done
Log: Init: Creating Gui::Application and QApplication
Log: Local server 'FreeCAD' started
Log: OpenGL version is: 4.5 (4.5.0 NVIDIA 390.87)
Log: Run Gui init script
Log: Init: Running FreeCADGuiInit.py start script...
Log: Init:   Searching modules...
Log: Init:      Initializing /usr/local/FreeCAD/Mod/AddonManager... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Arch... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Complete... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Draft... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Drawing... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Fem... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Idf(InitGui.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Image... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Import... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Inspection... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Material... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Measure(InitGui.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Mesh... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/MeshPart... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/OpenSCAD... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Part... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/PartDesign... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Path... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Plot... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Points... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Raytracing... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/ReverseEngineering... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Robot... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Ship... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Show(InitGui.py not found)... ignore
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Sketcher... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Spreadsheet... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Start... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Surface... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/TechDraw... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Test... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Tux... done
Log: Init:      Initializing /usr/local/FreeCAD/Mod/Web... done
Log: Init: Loading FreeCAD GUI
Log: Init: Running FreeCADGuiInit.py start script... done
Log: Init: Activating default workbench StartWorkbench
Log: Loading GUI of Web module... done
Log: Loading GUI of Start module... done
Log: Loading Start module... done
Log: libpng warning: iCCP: known incorrect sRGB profile
Log: libpng warning: iCCP: known incorrect sRGB profile
Log: Init: Showing main window
Log: Main window restored
Log: Show main window
Log: Toolbars restored
Log: Init: Entering event loop
Log: Init: Processing command line files
Log: Module: Part
Log: Loading Part module... done
Log: Loading Sketcher module... done
Log: Loading PartDesign module... done
Log: Loading GUI of Part module... done
Log: Loading GUI of Sketcher module... done
Log: Loading GUI of PartDesign module... done
Log: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1401, resource id: 10545895, major code: 40 (TranslateCoords), minor code: 0
Log: Loading Path module... done
Log: Loading PathStock... done
Log: Loading GUI of Path module... done
Log: Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
Log: Loading PathToolController... done
Log: Loading PathJobGui... done
Log: Loading Inspection module... done
Log: Loading TechDraw module... done
Log: Loading PathOpGui... done
Log: Loading PathComment... done
Log: Loading PathDeburrGui... done
Log: Loading PathDressup... done
Log: Loading DressupDogbone... done
Log: Loading Path_DressupDragKnife... done
Log: PathDressupRampEntry.NOTICE: Loading Path_DressupRampEntry... done

Log: PathDressupHoldingTags.NOTICE: Loading Path_DressupTag... done

Log: PathDressupTagGui.NOTICE: Loading PathDressupTagGui... done

Log: PathDressupLeadInOut.NOTICE: Loading PathDressupLeadInOut... done

Log: Loading PathDrillingGui... done
Log: Loading PathEngraveGui... done
Log: Loading PathFixture... done
Log: Loading PathHelixGui... done
Log: Loading PathHop... done
Log: Loading PathMillFaceGui... done
Log: Loading PathPocketGui... done
Log: Loading PathPocketShapeGui... done
Log: Loading PathPost... done
Log: Loading PathProfileContourGui... done
Log: Loading PathProfileEdgesGui... done
Log: Loading PathProfileFacesGui... done
Log: Loading Mesh module... done
Log: Loading PathSimulator module.... done
Log: Loading PathSimulator Gui... done
Log: Loading PathStop... done
Log: Loading MeshPart module... done
Log: Loading PathSurfaceGui... done
Log: Loading Path workbench... done
Msg: Path workbench activated
Err: Running the Python command 'Path_Job' failed:
Traceback (most recent call last):
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobCmd.py", line 64, in Activated
    dialog = PathJobDlg.JobCreate()
  File "/usr/local/FreeCAD/Mod/Path/PathScripts/PathJobDlg.py", line 55, in __init__
    self.dialog.templateGroup.hide()

'PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup'Log: Hide main window
Log: Finish: Event loop left
Log: Destruct Gui::Application
Log: FreeCAD terminating...
Log: Saving system parameter...
Log: Saving system parameter...done
Log: Saving user parameter...
Log: Saving user parameter...done
FreeCAD.log (11,876 bytes)   

Kunda1

2019-05-28 11:51

administrator   ~0013125

@cmt thanks for your ticket. please familiarize yourself with our bug tracker guidelines (large yellow banner at the top of the page). You'll have a higher probability of expedited response time if you post your bug reports directly to the forum. Thanks.

@sliptonic care to weigh in?

Kunda1

2019-05-30 12:14

administrator   ~0013129

@mlampert any thoughts as well ?

mlampert

2019-05-30 19:58

developer   ~0013132

I dont' have access to FreeBSD. From the looks of it though it's more a build/installation issue where `FreeCADGui.PySideUic.loadUi(..)` does not properly load or return the actual UI.

Maybe @kkremitzki has some insight?

cmt

2019-06-03 20:05

reporter   ~0013144

Do you know off-hand which file would be missing here? I've compared Path with working parts of FreeCAD and I can't spot anything wrong (that might be my fault, though). But then I'm quite sure we didn't simply "forget" to package a file - our (FreeBSD's) packaging tests would have failed in that case.
I hope I'll find some more time to debug this later this week.

cmt

2019-06-09 14:30

reporter   ~0013165

Last edited: 2019-06-09 14:33

To test the theory of the failing FreeCADGui.PySideUic.loadUi(..), I stuck a self.dialog.dumpObjectTree() right after the loadUi() call, this is what I get:

Log: QDialog::Dialog 
Log:     QFormInternal::TranslationWatcher:: 
Log:     QVBoxLayout::verticalLayout_2 
Log:     QWidget::widget_4 
Log:         QGridLayout::gridLayout_2 
Log:         QGroupBox::templateGroup 
Log:             QVBoxLayout::verticalLayout 
Log:             QComboBox::jobTemplate 
Log:                 QStandardItemModel:: 
Log:         QGroupBox::modelGroup 
Log:             QVBoxLayout::verticalLayout_6 
Log:             QTreeWidget::modelTree 
Log:                 QWidget::qt_scrollarea_viewport 
Log:                 QWidget::qt_scrollarea_hcontainer 
Log:                     QScrollBar:: 
Log:                     QBoxLayout:: 
Log:                 QWidget::qt_scrollarea_vcontainer 
Log:                     QScrollBar:: 
Log:                     QBoxLayout:: 
Log:                 QStyledItemDelegate:: 
Log:                 QHeaderView:: 
Log:                     QWidget::qt_scrollarea_viewport 
Log:                     QWidget::qt_scrollarea_hcontainer 
Log:                         QScrollBar:: 
Log:                         QBoxLayout:: 
Log:                     QWidget::qt_scrollarea_vcontainer 
Log:                         QScrollBar:: 
Log:                         QBoxLayout:: 
Log:                     QItemSelectionModel:: 
Log:                 QTreeModel:: 
Log:                 QItemSelectionModel:: 
Log:     QDialogButtonBox::buttonBox 
Log:         QHBoxLayout:: 
Log:         QPushButton:: 
Log:         QPushButton::

At first glance, that looks pretty complete - the templateGroup and the modelGroup elements are clearly present, but they don't show up on the Python side (self.dialog has no attribute templateGroup etc.)
I notice that there are not that many places under Mod/ which use similar patterns with the loadUi() call - a few places in Arch and Fem (which I haven't used so far) and quite a bunch in Path (where we're witnessing this problem). Could we be looking at some PySide2 and/or Qt thing here, like API changes in the more recent versions? (which pyside2 is in the AppImage?)

PS. gna, I hope this fixed the formatting. Web stuff, nuff said (I'm a text/plain kind of person).

mlampert

2019-06-09 18:54

developer   ~0013166

I ran into this same symptom this week when trying to create a custom widget in python. As soon as I tried to promote a widget to use my custom class I ended up getting an empty UI back from loadUI().

My best guess was the registration of FC's custom widgets doesn't work correctly. Off those widgets Path only uses "Gui::InputField". Having said that, DlgJobCreate.ui doesn't use any of those so the problem might be more fundamental.

Can you try manually loading these classes in the Python Console ?
If that works, can you create a simple ui file with the version of "designer" installed in BSD and see if you can load that one successfully through loadUI() in the Python Console?

wmayer

2019-06-12 14:23

administrator   ~0013186

Here a related forum thread:
https://forum.freecadweb.org/viewtopic.php?f=18&t=36647#p310940

cmt

2019-06-15 14:14

reporter   ~0013216

Some more poking:
Loading the modules in the python console works. Also, I can loadUi() a simple .ui file (just a checkbox), and dumpObjectTree() on those objects gives me the full tree as expected. What's missing is the automatic creation of attributes on the QDialog (etc) objects - that is, e.g. self.dialog.templateGroup is missing. But hen I can readily use findChild() to get at the UI elements - self.dialog.findCHild(QTGui.QGroupBox, "templateGroup") gives me the exactly that, and I can call hide() on that, etc.
Going through everything to find and change all the UI element operations this way seems rather tedious and I've no idea what might break - but I think it's clear that "something" in pyside2 changed. I'll try to dig into the AppImage and fin out how things were working there, maybe we can find an easy way to make the Path tool and other dialogs work again.

wmayer

2019-06-16 12:05

administrator   ~0013220

Have a look at my latest findings: https://forum.freecadweb.org/viewtopic.php?f=18&t=36647&p=314778#p314778

Kunda1

2019-06-16 14:23

administrator   ~0013221

Assigning to wmayer as he seems to have made headway on this issue.

cmt

2019-06-16 16:45

reporter   ~0013224

Ah, that's the hint I needed.
Executive version: the root cause of this whole mess are changes in PySide2's CMake files.

Long version: the old PySide2 (version 5.6 is being used in the AppImage files) defined, among some others, PYSIDE_INCLUDE_DIR, but that variable cannot be found anywhere in PySide2 5.12.x cmake files. This variable is used in FreeCAD's top level file when checking for PySide2. Unfortunately, that check is labeled QUIET, and even if there's a comment indicating PySide2 is required, there's no provision to bail out at this place. See https://github.com/FreeCAD/FreeCAD/blob/master/CMakeLists.txt#L1072 . Unless you inspect the build log very carefully, you never know that a required component couldn't be found. At the same time, enough parts of the whole PySide2/PySide2-Tools/Shiboken2 stack are found to let the build pass (e.g. we totally get pyside2-rcc). But at the same time, we don't get HAVE_PYSIDE2/HAVE_PYSIDE defined, and the code in createChildrenNameAttributes() is just dead.
To resolve this, we'll have to rework the way the PySide2 (etc) libraries are detected (use our own Find* files?), preferably without having to change stuff in the downstream code.
I found this by working from the other side - sticking some #error preprocessor statements into the #else block in createChildrenNameAttributes() and going backwards from that. This investigation wasn't helped by the absence of any usable hangelog in PySide2 - git log doesn't count, really.

cmt

2019-06-16 19:32

reporter   ~0013226

OK, that's it: better PySide2 detection fixes the Path tool (and the other places, I suspect but did not test for lack of time). The newer PySide2 releases (including the Shiboken2 etc, it's all part of the pyside2-everywhere distribution) export include dirs and library names not as cmake variables but as target attributes. To stay compatible with the old pyside2 packages, we have to check both ways. See attached patch (git format-patch), or do you prefer a github pull request?).
0001-fix-detection-of-recent-versions-of-PySide2.patch (2,376 bytes)   
From 66db0f0a03af640a24e6457e3a63850e9d8e642a Mon Sep 17 00:00:00 2001
From: Christoph Moench-Tegeder <cmt@burggraben.net>
Date: Sun, 16 Jun 2019 21:17:46 +0200
Subject: [PATCH] fix detection of recent versions of PySide2

sometime between releases 5.6 and 5.12, the PySide2 project
reorganized their cmake files and the variables exported by
those files. In order to enable building FreeCAD with the newer
PySide2 (and Shiboken2 etc) packages with minimal changes, this
leaves the old PySide2 detection intact and tries using the
cmake properties used by the newer PySide2 releases. As a bonus,
cmake now reports an error, if PySide2 or Shiboken2 are not
found.
---
 CMakeLists.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index acd65efbe..dbae6406d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1063,6 +1063,13 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
             endif()
         endif()
 
+        # pyside2 changed it's cmake files, this is the dance we have
+        # to dance to be compatible with the old and the new versions
+        if(SHIBOKEN_PYTHON_INCLUDE_DIRS AND NOT SHIBOKEN_INCLUDE_DIR)
+          get_property(SHIBOKEN_INCLUDE_DIR TARGET Shiboken2::libshiboken PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+            get_property(SHIBOKEN_LIBRARY TARGET Shiboken2::libshiboken PROPERTY IMPORTED_LOCATION_RELEASE)
+        endif(SHIBOKEN_PYTHON_INCLUDE_DIRS AND NOT SHIBOKEN_INCLUDE_DIR)
+
         if(NOT SHIBOKEN_INCLUDE_DIR)
             message("====================\n"
                     "shiboken2 not found.\n"
@@ -1070,6 +1077,14 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
         endif(NOT SHIBOKEN_INCLUDE_DIR)
 
         find_package(PySide2 QUIET)# REQUIRED
+
+        # pyside2 changed it's cmake files, this is the dance we have
+        # to dance to be compatible with the old and the new versions
+        if(NOT PYSIDE_INCLUDE_DIR)
+          get_property(PYSIDE_INCLUDE_DIR TARGET PySide2::pyside2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+          get_property(PYSIDE_LIBRARY TARGET PySide2::pyside2 PROPERTY IMPORTED_LOCATION_RELEASE)
+        endif(NOT PYSIDE_INCLUDE_DIR)
+
         if(NOT PYSIDE_INCLUDE_DIR)
             message("==================\n"
                     "PySide2 not found.\n"
-- 
2.22.0

Kunda1

2019-06-20 07:42

administrator   ~0013278

Changed ticket status from 'bug' to 'patch'

ascaron

2019-06-22 10:37

reporter   ~0013294

After applying the patch on Manjaro these are the values of the properties:
SHIBOKEN_INCLUDE_DIR: /usr/include/shiboken2/usr/include/python3.7m
SHIBOKEN_LIBRARY: /usr/lib/libshiboken2.cpython-37m-x86_64-linux-gnu.so.5.12.3
PYSIDE_INCLUDE_DIR: /usr/include/PySide2
PYSIDE_LIBRARY:

SHIBOKEN_INCLUDE_DIR is messed up and PYSIDE_LIBRARY empty. After applying correct paths manually everything seems to work.
I installed PySide2 and Shiboken2 from the official Manjaro repositories which should be copies from the Arch repositories. No idea whats wrong there.

OS: Manjaro Linux (dwm/dwm)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17070 (Git)
Build type: Release
Branch: master
Hash: 4e4631707ead2e9e20826ed354b33b2c4a921230
Python version: 3.7.3
Qt version: 5.12.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)

wmayer

2019-06-22 10:49

administrator   ~0013295

The change in commit cabb7339 fixes the issue without making PySide a mandatory build dependency.

For the future I will add a cmake option where the user then can decide to link PySide at build time (therefore I integrate your parch) or use PySide as Python module at runtime.

Kunda1

2020-12-07 15:56

administrator   ~0015111

@wmayer can we close this ticket or is there something left to do?

chennes

2021-12-17 05:14

administrator   ~0016111

Fixed by https://github.com/FreeCAD/FreeCAD/commit/cabb7339

Related Changesets

FreeCAD: master cabb7339

2019-06-22 10:32:36

wmayer

Details Diff
issue 0003984: Creating a Path Job object fails with 'PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup' Affected Issues
0003984
mod - src/Gui/WidgetFactory.cpp Diff File

FreeCAD: releases/FreeCAD-0-18 60fd668d

2019-06-22 10:32:36

wmayer

Details Diff
issue 0003984: Creating a Path Job object fails with 'PySide2.QtWidgets.QDialog' object has no attribute 'templateGroup' Affected Issues
0003984
mod - src/Gui/WidgetFactory.cpp Diff File

Issue History

Date Modified Username Field Change
2019-05-20 17:13 cmt New Issue
2019-05-20 17:13 cmt File Added: FreeCAD.log
2019-05-28 11:51 Kunda1 Note Added: 0013125
2019-05-28 11:51 Kunda1 Tag Attached: FreeBSD
2019-05-30 12:14 Kunda1 Note Added: 0013129
2019-05-30 19:58 mlampert Note Added: 0013132
2019-06-03 20:05 cmt Note Added: 0013144
2019-06-09 14:30 cmt Note Added: 0013165
2019-06-09 14:33 cmt Note Edited: 0013165
2019-06-09 18:54 mlampert Note Added: 0013166
2019-06-12 14:23 wmayer Note Added: 0013186
2019-06-15 14:14 cmt Note Added: 0013216
2019-06-16 12:05 wmayer Note Added: 0013220
2019-06-16 14:23 Kunda1 Assigned To => wmayer
2019-06-16 14:23 Kunda1 Status new => confirmed
2019-06-16 14:23 Kunda1 Note Added: 0013221
2019-06-16 14:23 Kunda1 Target Version => 0.19
2019-06-16 16:45 cmt Note Added: 0013224
2019-06-16 19:32 cmt File Added: 0001-fix-detection-of-recent-versions-of-PySide2.patch
2019-06-16 19:32 cmt Note Added: 0013226
2019-06-20 07:42 Kunda1 Category Bug => Patch
2019-06-20 07:42 Kunda1 Note Added: 0013278
2019-06-22 10:33 wmayer Changeset attached => FreeCAD master cabb7339
2019-06-22 10:37 ascaron Note Added: 0013294
2019-06-22 10:49 wmayer Note Added: 0013295
2019-06-22 12:39 wmayer Changeset attached => FreeCAD releases/FreeCAD-0-18 60fd668d
2020-12-07 15:56 Kunda1 Note Added: 0015111
2021-02-06 06:33 abdullah Target Version => 0.20
2021-12-17 05:14 chennes Status confirmed => closed
2021-12-17 05:14 chennes Resolution open => fixed
2021-12-17 05:14 chennes Note Added: 0016111