From 9c71e9db02b0fcf5555f3cdb8ea7c9cb682a8e71 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 17 Feb 2023 14:48:52 +0000 Subject: [PATCH] Speculative fix for race during performance counter selection * If the window is closed while counter enumeration is happening and that takes long enough this might break, so keep a QPointer around. --- .../Dialogs/PerformanceCounterSelection.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp index dcb018cb6..1def5fb07 100644 --- a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp +++ b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp @@ -253,17 +253,21 @@ PerformanceCounterSelection::PerformanceCounterSelection(ICaptureContext &ctx, ui->counterTree->setMouseTracking(true); - ctx.Replay().AsyncInvoke([this, selectedCounters](IReplayController *controller) { + QPointer ptr(this); + ctx.Replay().AsyncInvoke([this, ptr, selectedCounters](IReplayController *controller) { QVector counterDescriptions; for(const GPUCounter counter : controller->EnumerateCounters()) { counterDescriptions.append(controller->DescribeCounter(counter)); } - GUIInvoke::call(this, [counterDescriptions, selectedCounters, this]() { - SetCounters(counterDescriptions); - SetSelectedCounters(selectedCounters); - }); + if(ptr) + { + GUIInvoke::call(this, [counterDescriptions, selectedCounters, this]() { + SetCounters(counterDescriptions); + SetSelectedCounters(selectedCounters); + }); + } }); }