From 378314aafb2bf4523c810a933c05e79b366737ef Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 20 Aug 2019 10:58:07 +0800 Subject: [PATCH] Gui: try to fix property editor crash Crash stack trace https://forum.freecadweb.org/viewtopic.php?f=8&t=37757&e=1&view=unread#p327901 It appears to by caused by handling QAbstractItemDelegate::closeEditor signal twice. Once inside PropertyItemDelegate::editorClosed via slot connection where the editor is closed/destroyed, the other in PropertyEditor::closeEditor() which tries to access the destroyed editor. This patch removes handling of closeEditor signal in PropertyItemDelegate. --- src/Gui/propertyeditor/PropertyEditor.cpp | 1 - .../propertyeditor/PropertyItemDelegate.cpp | 22 ------------------- src/Gui/propertyeditor/PropertyItemDelegate.h | 1 - 3 files changed, 24 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 9cade63ee5..6daf4f734a 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -153,7 +153,6 @@ void PropertyEditor::commitData (QWidget * editor) void PropertyEditor::editorDestroyed (QObject * editor) { - delegate->editorClosed(0,QAbstractItemDelegate::NoHint); QTreeView::editorDestroyed(editor); } diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index 562c4d9750..46af8cc376 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -47,8 +47,6 @@ PropertyItemDelegate::PropertyItemDelegate(QObject* parent) : QItemDelegate(parent), expressionEditor(0) , pressed(false), changed(false) { - connect(this, SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)), - this, SLOT(editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint))); } PropertyItemDelegate::~PropertyItemDelegate() @@ -123,26 +121,6 @@ bool PropertyItemDelegate::editorEvent (QEvent * event, QAbstractItemModel* mode return QItemDelegate::editorEvent(event, model, option, index); } -void PropertyItemDelegate::editorClosed(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) -{ -#if 0 - int id = 0; - auto &app = App::GetApplication(); - const char *name = app.getActiveTransaction(&id); - if(id && id==activeTransactionID) { - FC_LOG("editor close transaction " << name); - app.closeActiveTransaction(false,id); - activeTransactionID = 0; - } - FC_LOG("editor close " << editor); -#endif - - // don't close the editor when pressing Tab or Shift+Tab - // https://forum.freecadweb.org/viewtopic.php?f=3&t=34627#p290957 - if (editor && hint != EditNextItem && hint != EditPreviousItem) - editor->close(); -} - QWidget * PropertyItemDelegate::createEditor (QWidget * parent, const QStyleOptionViewItem & /*option*/, const QModelIndex & index ) const { diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.h b/src/Gui/propertyeditor/PropertyItemDelegate.h index 96c24a3c89..f2ae422954 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.h +++ b/src/Gui/propertyeditor/PropertyItemDelegate.h @@ -47,7 +47,6 @@ public: public Q_SLOTS: void valueChanged(); - void editorClosed (QWidget * editor, QAbstractItemDelegate::EndEditHint hint); private: mutable QWidget *expressionEditor;