Use QPointer to track live capture windows during Shutdown

The save capture modal message box could process messages which could delete a LiveCapture, the pointer had already been copied into a local list, then try to use deleted memory.
This commit is contained in:
Jake Turner
2023-08-17 18:04:41 +01:00
parent d0388f1f20
commit b2c97f2cf3
+13 -5
View File
@@ -2942,14 +2942,22 @@ void MainWindow::closeEvent(QCloseEvent *event)
bool noToAll = false;
QList<LiveCapture *> liveCaptures = m_LiveCaptures;
QList<QPointer<LiveCapture>> liveCaptures;
int unsavedCaps = 0;
for(LiveCapture *live : liveCaptures)
unsavedCaps += live->unsavedCaptureCount();
for(LiveCapture *live : liveCaptures)
for(QPointer<LiveCapture> live : m_LiveCaptures)
{
unsavedCaps += live->unsavedCaptureCount();
liveCaptures.append(live);
}
for(QPointer<LiveCapture> live : liveCaptures)
{
// The live capture could be deleted during this loop via the save capture modal message box
// message pump of an earlier live capture
if(live.isNull())
continue;
// if the user previously selected 'no to all' in the save prompts below, apply that to all
// subsequent live captures by skipping the check and unconditionally cleaning all captures
if(!noToAll)