Show error message in frontend if video encoding failed in engine
authorWuzzy <Wuzzy2@mail.ru>
Thu, 17 Jan 2019 23:46:00 +0100
changeset 14634 8ffa0c27f434
parent 14633 a049926fcdd3
child 14635 957db6db1a49
Show error message in frontend if video encoding failed in engine
QTfrontend/net/recorder.cpp
QTfrontend/net/recorder.h
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/page/pagevideos.h
--- a/QTfrontend/net/recorder.cpp	Thu Jan 17 22:48:14 2019 +0100
+++ b/QTfrontend/net/recorder.cpp	Thu Jan 17 23:46:00 2019 +0100
@@ -23,6 +23,7 @@
 #include "gameuiconfig.h"
 #include "hwconsts.h"
 #include "game.h"
+#include "util/MessageDialog.h"
 #include "LibavInteraction.h"
 
 // Encoding is memory expensive process, so we need to limit maximum number
@@ -76,6 +77,16 @@
         case 'v':
             finished = true;
             break;
+        case 'E':
+            int size = msg.size();
+            emit ErrorMessage(
+                tr("A fatal ERROR occured while processing the video recording! "
+                "The video could not be saved.\n\n"
+                "As a workaround, you could try to reset the Hedgewars video recorder settings to the defaults.\n\n"
+                "To report this error, please click the 'Feedback' button in the main menu!\n\n"
+                "Last engine message:\n%1")
+                .arg(QString::fromUtf8(msg.mid(2).left(size - 4))));
+            return;
         }
     }
 }
--- a/QTfrontend/net/recorder.h	Thu Jan 17 22:48:14 2019 +0100
+++ b/QTfrontend/net/recorder.h	Thu Jan 17 23:46:00 2019 +0100
@@ -51,6 +51,7 @@
     signals:
         void onProgress(float progress); // 0 < progress < 1
         void encodingFinished(bool success);
+        void ErrorMessage(const QString &);
 
     private:
         bool finished;
--- a/QTfrontend/ui/page/pagevideos.cpp	Thu Jan 17 22:48:14 2019 +0100
+++ b/QTfrontend/ui/page/pagevideos.cpp	Thu Jan 17 23:46:00 2019 +0100
@@ -48,6 +48,7 @@
 #include "gameuiconfig.h"
 #include "recorder.h"
 #include "ask_quit.h"
+#include "util/MessageDialog.h"
 
 static const QSize ThumbnailSize(350, 350*3/5);
 
@@ -315,6 +316,7 @@
     progressBar->setValue(0);
     connect(pRecorder, SIGNAL(onProgress(float)), this, SLOT(updateProgress(float)));
     connect(pRecorder, SIGNAL(encodingFinished(bool)), this, SLOT(encodingFinished(bool)));
+    connect(pRecorder, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowFatalErrorMessage(const QString &)), Qt::QueuedConnection);
     filesTable->setCellWidget(row, vcProgress, progressBar);
 
     numRecorders++;
@@ -742,3 +744,8 @@
     }
 }
 
+void PageVideos::ShowFatalErrorMessage(const QString & msg)
+{
+    MessageDialog::ShowFatalMessage(msg, this);
+}
+
--- a/QTfrontend/ui/page/pagevideos.h	Thu Jan 17 22:48:14 2019 +0100
+++ b/QTfrontend/ui/page/pagevideos.h	Thu Jan 17 23:46:00 2019 +0100
@@ -86,6 +86,7 @@
         void deleteSelectedFiles();
         void openVideosDirectory();
         void updateFileList(const QString & path);
+        void ShowFatalErrorMessage(const QString & msg);
 };
 
 #endif // PAGE_VIDEOS_H