diff --git a/thumbnail/djvucreator.cpp b/thumbnail/djvucreator.cpp --- a/thumbnail/djvucreator.cpp +++ b/thumbnail/djvucreator.cpp @@ -37,7 +37,7 @@ #include #include - +#include extern "C" { @@ -49,6 +49,9 @@ bool DjVuCreator::create(const QString &path, int width, int height, QImage &img) { + if (QStandardPaths::findExecutable(QStringLiteral("ddjvu")).isEmpty()) + return false; + int output[2]; QByteArray data(1024, 'k'); bool ok = false; @@ -71,13 +74,15 @@ pid_t pid = fork(); if (pid == 0) { + // child process close(output[0]); dup2(output[1], STDOUT_FILENO); execvp(argv[0], const_cast(argv)); - exit(1); + _exit(1); } - else if (pid >= 0) + else if (pid > 0) { + // parent process close(output[1]); int offset = 0; while (!ok) { @@ -116,6 +121,7 @@ } else { + // error case close(output[1]); }