Fix frontend crash when rapidly aborting many active video encodings. Fixes bug 595
authorWuzzy <Wuzzy2@mail.ru>
Wed, 08 Aug 2018 18:36:12 +0200
changeset 13644 1b536e268519
parent 13643 690cc84e9fd6
child 13645 fc46cb95c6d7
child 13646 67d8f75f048d
Fix frontend crash when rapidly aborting many active video encodings. Fixes bug #595
ChangeLog.txt
QTfrontend/net/recorder.cpp
QTfrontend/net/recorder.h
QTfrontend/ui/page/pagevideos.cpp
--- a/ChangeLog.txt	Wed Aug 08 15:22:34 2018 +0200
+++ b/ChangeLog.txt	Wed Aug 08 18:36:12 2018 +0200
@@ -32,6 +32,7 @@
 
 Frontend:
  + Add setting to disable audio dampening when losing window focus
+ * Fix rare crash when aborting video encoding in progress
  * Controllers are detected again
  * No longer allow having schemes with equal names (case-insensitive)
  * Lobby/room: No longer allow opening context menu if no player selected
--- a/QTfrontend/net/recorder.cpp	Wed Aug 08 15:22:34 2018 +0200
+++ b/QTfrontend/net/recorder.cpp	Wed Aug 08 18:36:12 2018 +0200
@@ -39,6 +39,7 @@
     this->prefix = prefix;
     item = 0;
     finished = false;
+    aborted = false;
     name = prefix + "." + LibavInteraction::instance().getExtension(config->AVFormat());
 }
 
@@ -152,3 +153,10 @@
 {
     return true;
 }
+
+void HWRecorder::abort()
+{
+    queue.removeOne(this);
+    aborted = true;
+    deleteLater();
+}
--- a/QTfrontend/net/recorder.h	Wed Aug 08 15:22:34 2018 +0200
+++ b/QTfrontend/net/recorder.h	Wed Aug 08 18:36:12 2018 +0200
@@ -35,6 +35,7 @@
         virtual ~HWRecorder();
 
         void EncodeVideo(const QByteArray & record);
+        void abort();
         bool simultaneousRun();
 
         VideoItem * item; // used by pagevideos
@@ -53,6 +54,7 @@
 
     private:
         bool finished;
+        bool aborted;
         GameUIConfig * config;
 };
 
--- a/QTfrontend/ui/page/pagevideos.cpp	Wed Aug 08 15:22:34 2018 +0200
+++ b/QTfrontend/ui/page/pagevideos.cpp	Wed Aug 08 18:36:12 2018 +0200
@@ -594,9 +594,9 @@
     if (reallyDeleteMsg.exec() != QMessageBox::Ok)
         return;
 
-    // remove
+    // abort / remove
     if (!item->ready())
-        item->pRecorder->deleteLater();
+        item->pRecorder->abort();
     else
     {
         cfgdir->remove("Videos/" + item->name);