diff --git a/plugins/standardoutputview/outputwidget.h b/plugins/standardoutputview/outputwidget.h --- a/plugins/standardoutputview/outputwidget.h +++ b/plugins/standardoutputview/outputwidget.h @@ -55,6 +55,8 @@ public: OutputWidget(QWidget* parent, const ToolViewData* data); + ~OutputWidget() override; + void removeOutput( int id ); void raiseOutput( int id ); public Q_SLOTS: diff --git a/plugins/standardoutputview/outputwidget.cpp b/plugins/standardoutputview/outputwidget.cpp --- a/plugins/standardoutputview/outputwidget.cpp +++ b/plugins/standardoutputview/outputwidget.cpp @@ -195,6 +195,21 @@ enableActions(); } +OutputWidget::~OutputWidget() +{ + // Since QSharedPointer can't detect object destruction and our handled views/models objects + // have QObject parents we must first clear out hash. This removes double-free problem which + // happens when our objects are first destroyed from parent's destructor and sencond from + // QSharedPointer destructor. + m_views.clear(); + + // We also must manually destroy our widget here to prevent updateFilter() slot calling from + // parent's destructor, which leads to segfault since m_views hash will be destroyed before + // such call. + delete m_tabwidget; + delete m_stackwidget; +} + void OutputWidget::clearModel() { auto view = qobject_cast(currentWidget());