]> sigrok.org Git - pulseview.git/commitdiff
Trace: Make popup forms compatible with OSX
authorElias Oenal <redacted>
Thu, 19 May 2016 18:34:45 +0000 (20:34 +0200)
committerSoeren Apel <redacted>
Thu, 19 May 2016 18:34:45 +0000 (20:34 +0200)
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.

pv/view/trace.cpp

index ea443f23b91cebf4ddb141b64ae3ef4af705b357..87d3dc1dc095fa7ebd7b1dd2b7dba0bf5c255c8e 100644 (file)
@@ -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_);