View Issue Details

IDProjectCategoryView StatusLast Update
0003984PathPatchpublic2021-02-06 06:33
Reportercmt Assigned Towmayer  
PrioritynormalSeveritymajorReproducibilityalways
Status confirmedResolutionopen 
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 (Attachment missing)

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 (Attachment missing)

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?

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