[TCAS] Fixed "mixed" values for debug/TCAS xswiftbus.conf file

Also only update if simulator XPlane is not connected, otherwise values are updated there
This allows to update the values BEFORE XPlane starts and avoids a restart
This commit is contained in:
Klaus Basan
2020-03-19 18:16:00 +01:00
committed by Mat Sutcliffe
parent 2607ebd7c6
commit 3d1dad989e
4 changed files with 34 additions and 14 deletions

View File

@@ -6,9 +6,10 @@
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "simulatorxplaneconfigwindow.h"
#include "blackcore/application.h"
#include "ui_simulatorxplaneconfigwindow.h"
#include "simulatorxplaneconfigwindow.h"
#include "blackcore/context/contextsimulator.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/simulation/xplane/xswiftbusconfigwriter.h"
#include <QComboBox>
@@ -16,6 +17,7 @@
#include <vector>
using namespace BlackGui;
using namespace BlackCore::Context;
using namespace BlackMisc;
using namespace BlackMisc::Simulation::Settings;
using namespace BlackMisc::Simulation::XPlane;
@@ -48,16 +50,25 @@ namespace BlackSimPlugin
void CSimulatorXPlaneConfigWindow::onSettingsAccepted()
{
if (!sGui || sGui->isShuttingDown()) { return; }
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.getThreadLocal();
const CXSwiftBusSettings changed = this->getSettingsFromUI();
if (s != changed)
{
m_xSwiftBusServerSettings.set(changed);
CXSwiftBusConfigWriter xswiftbusConfigWriter;
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
xswiftbusConfigWriter.setDebugMode(s.isLogRenderPhases());
xswiftbusConfigWriter.setTcasEnabled(s.isTcasEnabled());
xswiftbusConfigWriter.updateInAllXPlaneVersions();
// this writes to a local XPlane directory
// if swift runs distributed it does nothing
// if XPlane is connected the settings will be written from config.cpp
if (!sGui->getIContextSimulator() || !sGui->getIContextSimulator()->isSimulatorSimulating())
{
CXSwiftBusConfigWriter xswiftbusConfigWriter;
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
xswiftbusConfigWriter.setDebugMode(changed.isLogRenderPhases());
xswiftbusConfigWriter.setTcasEnabled(changed.isTcasEnabled());
xswiftbusConfigWriter.updateInAllXPlaneVersions();
}
}
this->close();
}