mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -17,58 +17,55 @@ using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
namespace Simulation
|
||||
QProcess *CModelConverterX::s_proccess = nullptr;
|
||||
|
||||
bool CModelConverterX::supportsModelConverterX()
|
||||
{
|
||||
QProcess *CModelConverterX::s_proccess = nullptr;
|
||||
if (!CBuildConfig::isRunningOnWindowsNtPlatform()) { return false; }
|
||||
return !getBinary().isEmpty();
|
||||
}
|
||||
|
||||
bool CModelConverterX::supportsModelConverterX()
|
||||
QProcess *CModelConverterX::startModelConverterX(const CAircraftModel &model, QObject *parent)
|
||||
{
|
||||
// checks
|
||||
if (model.getFileName().isEmpty()) { return nullptr; }
|
||||
const QString modelConverterX = getBinary();
|
||||
if (modelConverterX.isEmpty()) { return nullptr; }
|
||||
|
||||
// delete other MCX
|
||||
if (s_proccess)
|
||||
{
|
||||
if (!CBuildConfig::isRunningOnWindowsNtPlatform()) { return false; }
|
||||
return !getBinary().isEmpty();
|
||||
}
|
||||
|
||||
QProcess *CModelConverterX::startModelConverterX(const CAircraftModel &model, QObject *parent)
|
||||
{
|
||||
// checks
|
||||
if (model.getFileName().isEmpty()) { return nullptr; }
|
||||
const QString modelConverterX = getBinary();
|
||||
if (modelConverterX.isEmpty()) { return nullptr; }
|
||||
|
||||
// delete other MCX
|
||||
if (s_proccess)
|
||||
QProcess *old = s_proccess;
|
||||
s_proccess = nullptr;
|
||||
if (old->state() == QProcess::Running)
|
||||
{
|
||||
QProcess *old = s_proccess;
|
||||
s_proccess = nullptr;
|
||||
if (old->state() == QProcess::Running)
|
||||
{
|
||||
// if still running, terminate and then delete
|
||||
QObject::connect(old, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), old, &QObject::deleteLater);
|
||||
old->terminate();
|
||||
}
|
||||
else
|
||||
{
|
||||
old->deleteLater();
|
||||
}
|
||||
// if still running, terminate and then delete
|
||||
QObject::connect(old, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), old, &QObject::deleteLater);
|
||||
old->terminate();
|
||||
}
|
||||
else
|
||||
{
|
||||
old->deleteLater();
|
||||
}
|
||||
|
||||
QProcess *process = new QProcess(parent);
|
||||
const QString argument = QDir::toNativeSeparators(model.getFileName());
|
||||
process->setProgram(modelConverterX);
|
||||
process->setArguments({argument});
|
||||
process->start();
|
||||
s_proccess = process;
|
||||
return process;
|
||||
}
|
||||
|
||||
QString CModelConverterX::getBinary()
|
||||
{
|
||||
static const BlackMisc::CSettingReadOnly<TModelConverterXBinary> setting(new QObject());
|
||||
const QString mcx = setting.get();
|
||||
if (mcx.isEmpty()) return {};
|
||||
const QFile f(mcx);
|
||||
return (f.exists()) ? mcx : QString();
|
||||
}
|
||||
} // ns
|
||||
QProcess *process = new QProcess(parent);
|
||||
const QString argument = QDir::toNativeSeparators(model.getFileName());
|
||||
process->setProgram(modelConverterX);
|
||||
process->setArguments({argument});
|
||||
process->start();
|
||||
s_proccess = process;
|
||||
return process;
|
||||
}
|
||||
|
||||
QString CModelConverterX::getBinary()
|
||||
{
|
||||
static const BlackMisc::CSettingReadOnly<TModelConverterXBinary> setting(new QObject());
|
||||
const QString mcx = setting.get();
|
||||
if (mcx.isEmpty()) return {};
|
||||
const QFile f(mcx);
|
||||
return (f.exists()) ? mcx : QString();
|
||||
}
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user