From d378a632f37f163e4fb6f16cc381245d4c9af6ac Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 29 Jul 2018 01:02:39 +0200 Subject: [PATCH] Bugfix: a standalone LayoutView object made the application crash on exit Reason: at the Qt will destroy all top level widgets. Ruby/Python will now know of this, hence try to cleanup the object inside it's GC. There was an attempt to avoid this by deleting all top-level widgets before the application exits. But this failed for LayoutView objects because these will create other, dependet top-level widgets for the plugins. And the LayoutView wants to stay owner for them. --- src/lay/lay/layApplication.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index a6a44abc4..9fb258493 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -1399,10 +1399,16 @@ GuiApplication::shutdown () mp_mw = 0; } - // delete all other top level widgets for safety - we don't want Ruby clean them up for us + // detach all top level widgets from Ruby/Python - we don't want the interpreter do this + // for us. Qt will delete all top level widgets itself. + // NOTE: we must only detach (= "keep" on C++ side), not delete them as top level widgets + // may be owned by someone else. QWidgetList tl_widgets = topLevelWidgets (); for (QWidgetList::iterator w = tl_widgets.begin (); w != tl_widgets.end (); ++w) { - delete *w; + gsi::ObjectBase *gsi_obj = dynamic_cast (*w); + if (gsi_obj) { + gsi_obj->keep (); + } } if (mp_recorder) {