]> sigrok.org Git - pulseview.git/blobdiff - pv/view/trace.cpp
Update the popup when a decoder is stacked
[pulseview.git] / pv / view / trace.cpp
index 79255bec3f98fa4491a4e81c6cb4529c12b176f0..464cadcde2ede54aaa6b4c8e0f3fcae9a1308e9f 100644 (file)
@@ -183,10 +183,8 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent)
        using pv::widgets::Popup;
 
        _popup = new Popup(parent);
-       _popup_form = new QFormLayout(_popup);
-       _popup->setLayout(_popup_form);
 
-       populate_popup_form(_popup, _popup_form);
+       create_popup_form();
 
        connect(_popup, SIGNAL(closed()),
                this, SLOT(on_popup_closed()));
@@ -224,6 +222,22 @@ void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
        form->addRow(tr("Colour"), colour_button);
 }
 
+void Trace::create_popup_form()
+{
+       // Clear the layout
+
+       // Transfer the layout and the child widgets to a temporary widget
+       // which then goes out of scope destroying the layout and all the child
+       // widgets.
+       if (_popup_form)
+               QWidget().setLayout(_popup_form);
+
+       // Repopulate the popup
+       _popup_form = new QFormLayout(_popup);
+       _popup->setLayout(_popup_form);
+       populate_popup_form(_popup, _popup_form);
+}
+
 void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        QLineEdit *const name_edit = new QLineEdit(parent);