1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Fix readyRead crash

Fix percentage calc
This commit is contained in:
kelteseth 2018-11-15 17:14:13 +01:00
parent e4fe59db71
commit baa162d862

View File

@ -277,6 +277,7 @@ bool Create::createWallpaperVideoPreview()
#endif
proConvertImage.data()->start();
proConvertImage.data()->waitForFinished(-1);
QString tmpErrImg = proConvertImage.data()->readAllStandardError();
if (!tmpErrImg.isEmpty()) {
QFile previewImg(m_createWallpaperData.exportPath + "/preview.png");
@ -325,8 +326,16 @@ bool Create::createWallpaperVideo()
proConvertVideo.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe");
qDebug() << "Start converting video";
connect(proConvertVideo.data(), &QProcess::readyReadStandardOutput, this, [&]() {
QString tmpOut = proConvertVideo.data()->readAllStandardOutput();
connect(proConvertVideo.data(), &QProcess::readyRead, this, [&]() {
// Somehow readyRead gets seldom called in the end with an
// not valid QProcess pointer....
if(proConvertVideo.isNull()) {
qDebug() << "EROR NULL";
return;
}
QString tmpOut = proConvertVideo.data()->readAll();
qDebug() << tmpOut << m_createWallpaperData.length;
auto tmpList = tmpOut.split(QRegExp("\\s+"), QString::SkipEmptyParts);
if (tmpList.length() > 2) {
@ -336,12 +345,13 @@ bool Create::createWallpaperVideo()
if (!ok)
return;
float progress = currentFrame / m_createWallpaperData.length;
float progress = currentFrame / (m_createWallpaperData.length * m_createWallpaperData.framerate);
this->setProgress(progress);
}
this->processOutput(tmpOut);
});
},
Qt::QueuedConnection);
// For some reason we only get output if we use execute instead of start....?!
#ifdef Q_OS_WIN
@ -349,7 +359,7 @@ bool Create::createWallpaperVideo()
#endif
proConvertVideo.data()->start(QIODevice::ReadOnly);
proConvertVideo.data()->waitForFinished(-1);
disconnect(proConvertVideo.data(), &QProcess::readyReadStandardOutput, 0, 0);
disconnect(proConvertVideo.data(), &QProcess::readyRead, 0, 0);
QString out = proConvertVideo.data()->readAllStandardOutput();