Commit 98abf5a7 authored by John Tapsell's avatar John Tapsell

Fix crash when removing an item from a custom widget

parent 6c347709
......@@ -529,11 +529,20 @@ void QGCToolWidget::addToolWidget(QGCToolWidgetItem* widget)
ui->hintLabel = NULL;
}
connect(widget, SIGNAL(editingFinished()), this, SLOT(storeWidgetsToSettings()));
connect(widget, SIGNAL(destroyed()), this, SLOT(storeWidgetsToSettings()));
connect(widget, SIGNAL(destroyed()), this, SLOT(widgetRemoved()));
toolLayout->addWidget(widget);
toolItemList.append(widget);
}
void QGCToolWidget::widgetRemoved()
{
//Must static cast and not dynamic cast since the object is in the destructor
//and we only want to use it as a pointer value
QGCToolWidgetItem *widget = static_cast<QGCToolWidgetItem *>(QObject::sender());
toolItemList.removeAll(widget);
storeWidgetsToSettings();
}
void QGCToolWidget::exportWidget()
{
const QString widgetFileExtension(".qgw");
......
......@@ -102,6 +102,7 @@ protected slots:
void addCommand();
void addLabel();
void setTitle();
void widgetRemoved();
private:
/** Do not use this from outside the class to set the object name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment