From: Elias Oenal Date: Thu, 19 May 2016 18:34:45 +0000 (+0200) Subject: Trace: Make popup forms compatible with OSX X-Git-Tag: pulseview-0.4.0~294 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e300444978bad69c104ce49c862da53dbe682e50;p=pulseview.git Trace: Make popup forms compatible with OSX 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. --- diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index ea443f23..87d3dc1d 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -224,10 +224,14 @@ 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_); + // 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_);