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(); }); });