From c33eba8c60b99d00cd73c400d23b6f338ef32a85 Mon Sep 17 00:00:00 2001 From: Carlos Alves Date: Mon, 2 Nov 2020 00:53:29 -0300 Subject: [PATCH] Fix konsole crashes when rearranging split views I'll try to explain here what I saw in this bug. Following the BUG instructions, drag the terminal[2] and drop (here the "drop event" starts) -> the dragged terminal "ViewSplitter" become scheduled for deletion, but it will only happens when it is in event loop. -> And of course it is not in event loop yet, it is still the "drop event" and it call the "addTerminalDisplay" to add the dragged terminal to a "ViewSplitter". -> This makes count() counts this scheduled for deletion "ViewSplitter" and goes to the wrong "if". -> It adds the "ViewSplitter" with the terminals into a "marked for deletion" one, finishes the "drop event" and enters event loop (a crash without a memleak! everything in the tab is properly deleted). BUG: 411741 BUG: 412596 FIXED-IN: 20.12 --- src/widgets/ViewSplitter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/ViewSplitter.cpp b/src/widgets/ViewSplitter.cpp index f1986ab0..773fb3cb 100644 --- a/src/widgets/ViewSplitter.cpp +++ b/src/widgets/ViewSplitter.cpp @@ -137,6 +137,10 @@ void ViewSplitter::childEvent(QChildEvent *event) if (event->removed()) { if (count() == 0) { + auto *parent_splitter = qobject_cast(parentWidget()); + if (parent_splitter != nullptr) { + setParent(nullptr); + } deleteLater(); } if (findChild() == nullptr) {