From b9523b4864cae5680aceaeace64dc199a49ff1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 26 Feb 2025 10:16:55 +0100 Subject: [PATCH] Capture parentTile value, fix crash on macOS (#292) --- Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index 6a65e8be..7e4099c8 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -417,8 +417,11 @@ void TracePlot::finishContextMenu() contextmenu->addAction(removeTile); connect(removeTile, &QAction::triggered, [=]() { markedForDeletion = true; - QTimer::singleShot(0, [=](){ - parentTile->closeTile(); + // 'this' object will be deleted when returning function but the following lambda + // might be executed after that and we still need to know which tile to close. + // Capture parentTile explicitly by value + QTimer::singleShot(0, [p=this->parentTile](){ + p->closeTile(); }); });