Qt behaves differently on OSX regarding widget lifetime it seems,
causing the addition of a stacked decoder to crash PV.
According to Elias, the object popup_form_ gets destroyed, yet
it still has the parent popup_ which in turn will destroy it
again at the end of its life. Either removing the parent, or the
preliminary destruction, fixes the crash.
// 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_);
+ // which we delete after the event was handled. This way, the layout
+ // and all widgets contained therein are deleted after the event was
+ // handled, leaving the parent popup_ time to handle the change.
+ if (popup_form_) {
+ QWidget *suicidal = new QWidget();
+ suicidal->setLayout(popup_form_);
+ suicidal->deleteLater();
+ }
// Repopulate the popup
popup_form_ = new QFormLayout(popup_);