[SOLVED] QTimer: PySide vs PyQt5

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

[SOLVED] QTimer: PySide vs PyQt5

Post by flachyjoe »

Hi,
same code : https://github.com/FlachyJoe/FCPDWorkbe ... ver.py#L65
cause a segfault when used with PySide
but work well with PyQt5.

Has somebody an explanation?

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x41040) [0x7fea5e4db040]
#1  0x7fea5d70ec75 in PySide::WeakRef::create(_object*, void (*)(void*), void*) from /lib/x86_64-linux-gnu/libpyside2.cpython-39-x86_64-linux-gnu.so.5.15+0x25
#2  /lib/x86_64-linux-gnu/libpyside2.cpython-39-x86_64-linux-gnu.so.5.15(+0x16791) [0x7fea5d702791]
#3  /lib/x86_64-linux-gnu/libpyside2.cpython-39-x86_64-linux-gnu.so.5.15(+0x169b2) [0x7fea5d7029b2]
#4  0x7fea5d7018c8 in PySide::SignalManager::globalReceiver(QObject*, _object*) from /lib/x86_64-linux-gnu/libpyside2.cpython-39-x86_64-linux-gnu.so.5.15+0x1b8
#5  /usr/lib/python3/dist-packages/PySide2/QtCore.cpython-39-x86_64-linux-gnu.so(+0x1ff847) [0x7fea3aafe847]
#6  /usr/lib/python3/dist-packages/PySide2/QtCore.cpython-39-x86_64-linux-gnu.so(+0x1ffc7e) [0x7fea3aafec7e]
#7  /usr/lib/python3/dist-packages/PySide2/QtCore.cpython-39-x86_64-linux-gnu.so(+0x200eea) [0x7fea3aaffeea]
#8  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x110e03) [0x7fea5fccbe03]
#9  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_Call+0x60) [0x7fea5fc878e0]
#10  /lib/x86_64-linux-gnu/libpyside2.cpython-39-x86_64-linux-gnu.so.5.15(+0x1d225) [0x7fea5d709225]
#11  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0xd5ee6) [0x7fea5fc90ee6]
#12  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyEval_EvalFrameDefault+0x6fa2) [0x7fea5fc34a02]
#13  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x71da3) [0x7fea5fc2cda3]
#14  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_FastCallDictTstate+0x57) [0x7fea5fc874e7]
#15  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_Call_Prepend+0xe0) [0x7fea5fc87700]
#16  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x133ec6) [0x7fea5fceeec6]
#17  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x12902e) [0x7fea5fce402e]
#18  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_MakeTpCall+0x94) [0x7fea5fc85004]
#19  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyEval_EvalFrameDefault+0x8811) [0x7fea5fc36271]
#20  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x71da3) [0x7fea5fc2cda3]
#21  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0xccd9c) [0x7fea5fc87d9c]
#22  0x7fea60c94cc3 in Gui::Application::activateWorkbench(char const*) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x593
#23  0x7fea60cb5a14 in Gui::Application::sActivateWorkbenchHandler(_object*, _object*) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x74
#24  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x110de8) [0x7fea5fccbde8]
#25  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_MakeTpCall+0x94) [0x7fea5fc85004]
#26  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyEval_EvalFrameDefault+0x8811) [0x7fea5fc36271]
#27  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x1a98dc) [0x7fea5fd648dc]
#28  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyEval_EvalCodeWithName+0x52) [0x7fea5fd64c32]
#29  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyEval_EvalCodeEx+0x42) [0x7fea5fd64c82]
#30  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyEval_EvalCode+0x1f) [0x7fea5fd6011f]
#31  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x1ee8f5) [0x7fea5fda98f5]
#32  /lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyRun_StringFlags+0x97) [0x7fea5fdaa1e7]
#33  0x7fea6025e73a in Base::InterpreterSingleton::runString[abi:cxx11](char const*) from /usr/lib/freecad-python3/lib/libFreeCADBase.so+0x6a
#34  0x7fea60d54095 in Gui::Command::_runCommand(char const*, int, Gui::Command::DoCmd_Type, char const*) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x95
#35  0x7fea60d54227 in Gui::Command::_doCommand(char const*, int, Gui::Command::DoCmd_Type, char const*, ...) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0xe7
#36  0x7fea60d81a39 in StdCmdWorkbench::activated(int) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x129
#37  0x7fea60d57841 in Gui::Command::invoke(int, Gui::Command::TriggerSource) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x4d1
#38  /lib/x86_64-linux-gnu/libQt5Core.so.5(+0x2f0600) [0x7fea5ebaa600]
#39  0x7fea5f661b33 in QActionGroup::triggered(QAction*) from /lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x43
#40  /lib/x86_64-linux-gnu/libQt5Core.so.5(+0x2f0600) [0x7fea5ebaa600]
#41  0x7fea5f65dbd6 in QAction::triggered(bool) from /lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x46
#42  0x7fea5f660908 in QAction::activate(QAction::ActionEvent) from /lib/x86_64-linux-gnu/libQt5Widgets.so.5+0xa8
#43  0x7fea5eba002f in QObject::event(QEvent*) from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x1cf
#44  0x7fea5f664783 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x83
#45  0x7fea60d27050 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x90
#46  0x7fea5eb727ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x12a
#47  0x7fea5eb757e1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x171
#48  /lib/x86_64-linux-gnu/libQt5Core.so.5(+0x312ba7) [0x7fea5ebccba7]
#49  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x25b) [0x7fea5c6f08eb]
#50  /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0xa8d28) [0x7fea5c743d28]
#51  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x33) [0x7fea5c6ee023]
#52  0x7fea5ebcc204 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x64
#53  0x7fea5eb7111b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x12b
#54  0x7fea5eb79604 in QCoreApplication::exec() from /lib/x86_64-linux-gnu/libQt5Core.so.5+0x94
#55  0x7fea60c98bb0 in Gui::Application::runApplication() from /usr/lib/freecad-python3/lib/libFreeCADGui.so+0x1970
#56  freecad(+0x4e34) [0x55bee9ed1e34]
#57  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xd5) [0x7fea5e4c2565]
#58  freecad(+0x51ae) [0x55bee9ed21ae]
OS: Ubuntu 21.04 (XFCE/xubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.? 24503
Build type: Release
Branch: ? master
Hash: ? 71141d09640be0cb1f0c82a8278e27fad4069547
Python version: 3.9.2
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.1
Locale: French/France (fr_FR)
and
OS: Ubuntu 21.04 (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.26155
Build type: Release
Branch: master
Hash: 0926a4148bcff11249fd4f56bc30256102ffe105
Python version: 3.9.5
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.2
Locale: French/France (fr_FR)
Last edited by flachyjoe on Sun Oct 17, 2021 6:40 pm, edited 1 time in total.
- Flachy Joe -
Image
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: QTimer: PySide vs PyQt5

Post by openBrain »

Just a guess as I'm with a mobile now. As your class will contain some slots, I'm surprised it doesn't inherits QtCore.QObject.
Could you add the inheritance and call the super constructor? And hopefully it may be fine.

Also I would advise you to set 'self' as parent of the Qtimer, so if the instance is deleted, and eventually running timer won't segfault at timeout.
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: QTimer: PySide vs PyQt5

Post by flachyjoe »

openBrain wrote: Sun Oct 17, 2021 3:32 pm Could you add the inheritance and call the super constructor? And hopefully it may be fine.
You're right! Thank you!
- Flachy Joe -
Image
Post Reply