mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:19:24 +02:00
Fix aborted baking in oven cli
This commit is contained in:
parent
cb9a30413d
commit
6b098bfc6a
5 changed files with 20 additions and 18 deletions
|
@ -29,11 +29,11 @@
|
||||||
#include <QtCore/QUrlQuery>
|
#include <QtCore/QUrlQuery>
|
||||||
|
|
||||||
#include <ClientServerUtils.h>
|
#include <ClientServerUtils.h>
|
||||||
#include <FBXBaker.h>
|
|
||||||
#include <JSBaker.h>
|
|
||||||
#include <NodeType.h>
|
#include <NodeType.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <image/Image.h>
|
||||||
|
#include <TextureBaker.h>
|
||||||
|
|
||||||
#include "AssetServerLogging.h"
|
#include "AssetServerLogging.h"
|
||||||
#include "BakeAssetTask.h"
|
#include "BakeAssetTask.h"
|
||||||
|
|
|
@ -62,16 +62,20 @@ void BakeAssetTask::run() {
|
||||||
"-t", extension,
|
"-t", extension,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto _ovenProcess = new QProcess(this);
|
_ovenProcess.reset(new QProcess());
|
||||||
|
|
||||||
connect(_ovenProcess, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
connect(_ovenProcess.get(), static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
this, [this, tempOutputDir](int exitCode, QProcess::ExitStatus exitStatus) {
|
this, [this, tempOutputDir](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||||
qDebug() << "Baking process finished: " << exitCode << exitStatus;
|
qDebug() << "Baking process finished: " << exitCode << exitStatus;
|
||||||
|
|
||||||
if (exitStatus == QProcess::CrashExit) {
|
if (exitStatus == QProcess::CrashExit) {
|
||||||
_didFinish.store(true);
|
if (_wasAborted) {
|
||||||
QString errors = "Fatal error occurred while baking";
|
emit bakeAborted(_assetHash, _assetPath);
|
||||||
emit bakeFailed(_assetHash, _assetPath, errors);
|
} else {
|
||||||
|
_didFinish.store(true);
|
||||||
|
QString errors = "Fatal error occurred while baking";
|
||||||
|
emit bakeFailed(_assetHash, _assetPath, errors);
|
||||||
|
}
|
||||||
} else if (exitCode == OVEN_STATUS_CODE_SUCCESS) {
|
} else if (exitCode == OVEN_STATUS_CODE_SUCCESS) {
|
||||||
auto files = _outputDir.entryInfoList(QDir::Files);
|
auto files = _outputDir.entryInfoList(QDir::Files);
|
||||||
QVector<QString> outputFiles;
|
QVector<QString> outputFiles;
|
||||||
|
@ -111,6 +115,6 @@ void BakeAssetTask::run() {
|
||||||
|
|
||||||
void BakeAssetTask::abort() {
|
void BakeAssetTask::abort() {
|
||||||
if (!_wasAborted.exchange(true)) {
|
if (!_wasAborted.exchange(true)) {
|
||||||
_ovenProcess.terminate();
|
_ovenProcess->terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
AssetPath _assetPath;
|
AssetPath _assetPath;
|
||||||
QString _filePath;
|
QString _filePath;
|
||||||
QDir _outputDir;
|
QDir _outputDir;
|
||||||
QProcess _ovenProcess { nullptr };
|
std::unique_ptr<QProcess> _ovenProcess { nullptr };
|
||||||
std::atomic<bool> _wasAborted { false };
|
std::atomic<bool> _wasAborted { false };
|
||||||
std::atomic<bool> _didFinish { false };
|
std::atomic<bool> _didFinish { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern "C" FILE * __cdecl __iob_func(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(__APPLE__)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1088,19 +1088,17 @@ bool processIsRunning(int64_t pid) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
||||||
if (process) {
|
if (process) {
|
||||||
DWORD exitCodeOut;
|
DWORD exitCode;
|
||||||
if (GetExitCodeProcess(process, &exitCodeOut) != 0) {
|
if (GetExitCodeProcess(process, &exitCode) != 0) {
|
||||||
return exitCodeOut == STILL_ACTIVE;
|
return exitCode == STILL_ACTIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
#elif defined(Q_OS_LINUX) || defined(__APPLE__)
|
#else
|
||||||
if (kill(pid, 0) == -1) {
|
if (kill(pid, 0) == -1) {
|
||||||
return errno != ESRCH;
|
return errno != ESRCH;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
static_assert(false);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString&
|
||||||
inputUrl.setScheme("file");
|
inputUrl.setScheme("file");
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Type: " << type;
|
qDebug() << "Baking file type: " << type;
|
||||||
|
|
||||||
static const QString MODEL_EXTENSION { "fbx" };
|
static const QString MODEL_EXTENSION { "fbx" };
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString&
|
||||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
_baker->moveToThread(qApp->getNextWorkerThread());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
|
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
|
||||||
QApplication::exit(1);
|
QApplication::exit(OVEN_STATUS_CODE_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke the bake method on the baker thread
|
// invoke the bake method on the baker thread
|
||||||
|
|
Loading…
Reference in a new issue