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.
This commit is contained in:
baldurk
2023-02-17 14:48:52 +00:00
parent f05c4efde8
commit 9c71e9db02
@@ -253,17 +253,21 @@ PerformanceCounterSelection::PerformanceCounterSelection(ICaptureContext &ctx,
ui->counterTree->setMouseTracking(true);
ctx.Replay().AsyncInvoke([this, selectedCounters](IReplayController *controller) {
QPointer<PerformanceCounterSelection> ptr(this);
ctx.Replay().AsyncInvoke([this, ptr, selectedCounters](IReplayController *controller) {
QVector<CounterDescription> 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);
});
}
});
}