View Revisions: Issue #4258

Summary 0004258: FreeCAD crashes on "Edit datum" in PartDesign when datum in Part
Revision 2020-02-05 16:18 by Kunda1
Additional Information When looking closely at the crash report in Linux:


#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f972b816f20]
#1  0x7f9705befe74 in PartDesignGui::TaskDlgDatumParameters::accept() from .../PartDesignGui.so+0xb4
0000002  0x7f972e2ef509 in Gui::TaskView::TaskView::accept() from .../libFreeCADGui.so+0x59
0000003  0x7f972bf727b8 in QMetaObject::activate(QObject*, int, int, void**) from .../libQt5Core.so.5+0x780
This looks like a GUI/Qt segfault.


** "Edit datum" is defined in src/Mod/PartDesign/Gui/ViewProviderDatum.cpp:

void ViewProviderDatum::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
    QAction* act;
    act = menu->addAction(QObject::tr("Edit datum"), receiver, member);
    act->setData(QVariant((int)ViewProvider::Default));
}


**  setupContextMenu is called from :
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
setupContextMenu{
    assert(ViewProvider);
    parameter  = new TaskDatumParameters(ViewProvider);
    Content.push_back(parameter);
}

** TaskDatumParameters is constructed with:

TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *ViewProvider,QWidget *parent)
    : PartGui::TaskAttacher(ViewProvider, parent, QString::fromLatin1("PartDesign_") + ViewProvider->datumType,
              ViewProvider->datumText + tr(" parameters"))
              
** TaskDlgDatumParameters::accept is defined in
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:

    
** TaskDlgDatumParameters is defined in

    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
TaskDlgDatumParameters::TaskDlgDatumParameters(ViewProviderDatum *ViewProvider)
    : TaskDlgAttacher(ViewProvider, false)
    
** TaskDlgAttacher is defined in
    src/Mod/Part/Gui/TaskAttacher.cpp
    its constructor calls new TaskAttacher
    
    
** There is a TaskAttacher.ui in
    src/Mod/Part/Gui/TaskAttacher.ui
    where the window widget is called
    PartGui::TaskAttacher
    
    
** There is also a TaskAttachmentEditor.ui in:
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui
    with the same UI layout, where the window widget is called
    PartDesignGui::TaskDatumParameters
    
    
CONCLUSION: one of these 2 crashes FreeCAD with datum objects in App::Parts when called with "Edit datum" from PartDesign WB. Following the trail: "Edit datum > setupContextMenu > TaskDatumParameters > PartGui::TaskAttacher" , it looks like
src/Mod/Part/Gui/TaskAttacher.ui is the bad one.

ALSO: Since it is possible to edit the attachment of datum objects - and any object - with
>>> Gui.runCommand('Part_EditAttachment')
from the python console, and 'Part_EditAttachment' is defined in src/Mod/Part/AttachmentEditor/Commands.py, it looks like src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui is the good one.

Visually, both seem identical, except that in
    src/Mod/Part/Gui/TaskAttacher.ui the input fields are of type Gui::QuantitySpinbox and Gui::PrefQuantitySpinBox,
while in
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui they're all Gui::InputField
    


This problem seems to have been known before in src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:

****
    //we need to add the copied features to the body after the command action, as otherwise FreeCAD crashes unexplainably
    for(auto obj : copies) {
        if (pcActiveBody)
            pcActiveBody->addObject(obj);
        else if (pcActivePart)
            pcActivePart->addObject(obj);
    }
****
Revision 2020-01-27 14:16 by Zolko
Additional Information When looking closely at the crash report inLinux:

#0 /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f972b816f20]
#1 0x7f9705befe74 in PartDesignGui::TaskDlgDatumParameters::accept() from .../PartDesignGui.so+0xb4
0000002 0x7f972e2ef509 in Gui::TaskView::TaskView::accept() from .../libFreeCADGui.so+0x59
0000003 0x7f972bf727b8 in QMetaObject::activate(QObject*, int, int, void**) from .../libQt5Core.so.5+0x780

This looks like a GUI/Qt segfault.


** "Edit datum" is defined in src/Mod/PartDesign/Gui/ViewProviderDatum.cpp:
void ViewProviderDatum::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
    QAction* act;
    act = menu->addAction(QObject::tr("Edit datum"), receiver, member);
    act->setData(QVariant((int)ViewProvider::Default));
}


** setupContextMenu is called from :
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
setupContextMenu{
    assert(ViewProvider);
    parameter = new TaskDatumParameters(ViewProvider);
    Content.push_back(parameter);
}


** TaskDatumParameters is constructed with:
TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *ViewProvider,QWidget *parent)
    : PartGui::TaskAttacher(ViewProvider, parent, QString::fromLatin1("PartDesign_") + ViewProvider->datumType,
              ViewProvider->datumText + tr(" parameters"))

              
** TaskDlgDatumParameters::accept is defined in
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:

    
** TaskDlgDatumParameters is defined in
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
TaskDlgDatumParameters::TaskDlgDatumParameters(ViewProviderDatum *ViewProvider)
    : TaskDlgAttacher(ViewProvider, false)

    
** TaskDlgAttacher is defined in
    src/Mod/Part/Gui/TaskAttacher.cpp
    its constructor calls new TaskAttacher
    
    
** There is a TaskAttacher.ui in
    src/Mod/Part/Gui/TaskAttacher.ui
    where the window widget is called
    PartGui::TaskAttacher
    
    
** There is also a TaskAttachmentEditor.ui in:
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui
    with the same UI layout, where the window widget is called
    PartDesignGui::TaskDatumParameters
    
    
CONCLUSION: one of these 2 crashes FreeCAD with datum objects in App::Parts when called with "Edit datum" from PartDesign WB. Following the trail: "Edit datum > setupContextMenu > TaskDatumParameters > PartGui::TaskAttacher" , it looks like
src/Mod/Part/Gui/TaskAttacher.ui is the bad one.

ALSO: Since it is possible to edit the attachment of datum objects - and any object - with
>>> Gui.runCommand('Part_EditAttachment')
from the python console, and 'Part_EditAttachment' is defined in src/Mod/Part/AttachmentEditor/Commands.py, it looks like src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui is the good one.

Visually, both seem identical, except that in
    src/Mod/Part/Gui/TaskAttacher.ui the input fields are of type Gui::QuantitySpinbox and Gui::PrefQuantitySpinBox,
while in
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui they're all Gui::InputField
    


This problem seems to have been known before in src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
****
    //we need to add the copied features to the body after the command action, as otherwise FreeCAD crashes unexplainably
    for(auto obj : copies) {
        if (pcActiveBody)
            pcActiveBody->addObject(obj);
        else if (pcActivePart)
            pcActivePart->addObject(obj);
    }
****