Bad value not filtered - FreeCAD hangs/crashes

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Bad value not filtered - FreeCAD hangs/crashes

Post by wmayer »

Version: 0.17.9747 (Git)
You are > 2500 commits behind the version when this has been discussed!
Ideally, the Deviation box would not send the new value until it loses focus or you hit enter or whatever.
This may work in this special case but then may break the logic in other cases. As said above the property doesn't know anything about the context a property is used.
There are other places where this would be good too. I previously had trouble with the old drawing workbench when trying to move or scale views. Every digit typed caused an update and I had to wait ages to input the next digit.
In a few cases a feature updates itself when a property has changed but no document recompute is triggered. Might be possible that this happens here too.
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Bad value not filtered - FreeCAD hangs/crashes

Post by crobar »

I'm interested in seeing how this works, could you possibly give me a hint for finding where in the code the property update is handled (i.e. the event that is triggered by changing a property value)? If you're using the Qt mechanism I guess I'm looking for the signal and slots that are involved. I had a search but it's not immediately obvious.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Bad value not filtered - FreeCAD hangs/crashes

Post by wmayer »

When starting to edit a property item then e.g. the method PropertyFloatConstraintItem::createEditor is called where the receiver is the slot PropertyItemDelegate::valueChanged. This slot is connected to the appropriate signal of the widget, e.g. valudChanged of a spin box.

When the user changes the value in the spin box then Qt emits the valueChanged signal and thus directly invokes PropertyItemDelegate::valueChanged. This function then invokes the commitData signal of the QAbstractItemDelegate class which invokes the virtual method commitData of PropertyEditor that is a sub-class of QAbstractItemView.

Over some more steps this calls PropertyItem::setPropertyValue that sets the property of the view provider or document object.

The relevant stack trace is:

Code: Select all

1  PartGui::ViewProviderPartExt::onChanged                       ViewProviderExt.cpp
2  App::Property::hasSetValue                                    Property.cpp
3  App::PropertyFloatConstraint::setPyObject                     PropertyStandard.cpp
4  App::PropertyContainerPy::setCustomAttributes                 PropertyContainerPyImp.cpp
5  App::PropertyContainerPy::_setattr                            PropertyContainerPy.cpp
6  App::ExtensionContainerPy::_setattr                           ExtensionContainerPy.cpp
7  Gui::ViewProviderPy::_setattr                                 ViewProviderPy.cpp
8  Gui::ViewProviderDocumentObjectPy::_setattr                   ViewProviderDocumentObjectPy.cpp
9  Base::PyObjectBase::__setattro                                PyObjectBase.cpp
10 PyObject_SetAttr                                              object.c
11 PyEval_EvalFrameEx                                            ceval.c
12 PyEval_EvalCodeEx                                             ceval.c
13 PyEval_EvalCode                                               ceval.c
14 run_mod                                                       pythonrun.c
15 PyRun_StringFlags                                             pythonrun.c
16 Base::InterpreterSingleton::runString                         Interpreter.cpp
17 Gui::Command::runCommand                                      Command.cpp
18 Gui::PropertyEditor::PropertyItem::setPropertyValue           PropertyItem.cpp
19 Gui::PropertyEditor::PropertyFloatConstraintItem::setValue    PropertyItem.cpp
20 Gui::PropertyEditor::PropertyItem::setData                    PropertyItem.cpp
21 Gui::PropertyEditor::PropertyModel::setData                   PropertyModel.cpp
22 Gui::PropertyEditor::PropertyItemDelegate::setModelData       PropertyItemDelegate.cpp
23 QAbstractItemView::commitData                                 qabstractitemview.cpp
24 Gui::PropertyEditor::PropertyEditor::commitData               PropertyEditor.cpp
25 QAbstractItemView::qt_static_metacall                         moc_qabstractitemview.cpp
26 QMetaObject::activate                                         qobject.cpp
27 QMetaObject::activate                                         qobject.cpp
28 QAbstractItemDelegate::commitData                             moc_qabstractitemdelegate.cpp
29 Gui::PropertyEditor::PropertyItemDelegate::valueChanged       PropertyItemDelegate.cpp
30 Gui::PropertyEditor::PropertyItemDelegate::qt_static_metacall moc_PropertyItemDelegate.cpp
31 QMetaObject::activate                                         qobject.cpp
32 QMetaObject::activate                                         qobject.cpp
33 QDoubleSpinBox::valueChanged                                  moc_qspinbox.cpp
But again, it's not up to the property editor to delay the emission of the signals, it's up to the view provider or document object class to handle this accordingly.
Post Reply