Commit a546d9a6 authored by Don Gagne's avatar Don Gagne

Exit app immediately if missing required paramter

parent 14d9765c
...@@ -93,10 +93,10 @@ void AutoPilotPluginManager::_uasDeleted(UASInterface* uas) ...@@ -93,10 +93,10 @@ void AutoPilotPluginManager::_uasDeleted(UASInterface* uas)
int uasId = uas->getUASID(); int uasId = uas->getUASID();
Q_ASSERT(uasId != 0); Q_ASSERT(uasId != 0);
Q_ASSERT(_pluginMap.contains(autopilotType)); if (_pluginMap.contains(autopilotType) && _pluginMap[autopilotType].contains(uasId)) {
Q_ASSERT(_pluginMap[autopilotType].contains(uasId)); delete _pluginMap[autopilotType][uasId];
delete _pluginMap[autopilotType][uasId]; _pluginMap[autopilotType].remove(uasId);
_pluginMap[autopilotType].remove(uasId); }
} }
AutoPilotPlugin* AutoPilotPluginManager::getInstanceForAutoPilotPlugin(UASInterface* uas) AutoPilotPlugin* AutoPilotPluginManager::getInstanceForAutoPilotPlugin(UASInterface* uas)
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "FactBinder.h" #include "FactBinder.h"
#include "UASManager.h" #include "UASManager.h"
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "QGCApplication.h"
#include <QDebug> #include <QDebug>
FactBinder::FactBinder(void) : FactBinder::FactBinder(void) :
...@@ -83,8 +85,8 @@ void FactBinder::setName(const QString& name) ...@@ -83,8 +85,8 @@ void FactBinder::setName(const QString& name)
emit nameChanged(); emit nameChanged();
emit metaDataChanged(); emit metaDataChanged();
} else { } else {
qWarning() << "FAILED BINDING PARAM" << name << ": PARAM DOES NOT EXIST ON SYSTEM!"; QString panicMessage("Required parameter (component id: %1, name: %2), is missing from vehicle. QGroundControl cannot operate with this firmware revision. QGroundControl will now shut down.");
Q_ASSERT(false); qgcApp()->panicShutdown(panicMessage.arg(_componentId).arg(parsedName));
} }
} }
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "ParameterLoader.h" #include "ParameterLoader.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "QGCApplication.h"
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
...@@ -268,8 +269,12 @@ bool ParameterLoader::parameterExists(int componentId, const QString& name) ...@@ -268,8 +269,12 @@ bool ParameterLoader::parameterExists(int componentId, const QString& name)
Fact* ParameterLoader::getFact(int componentId, const QString& name) Fact* ParameterLoader::getFact(int componentId, const QString& name)
{ {
componentId = _actualComponentId(componentId); componentId = _actualComponentId(componentId);
Q_ASSERT(_mapParameterName2Variant.contains(componentId));
Q_ASSERT(_mapParameterName2Variant[componentId].contains(name)); if (!_mapParameterName2Variant.contains(componentId) || !_mapParameterName2Variant[componentId].contains(name)) {
QString panicMessage("Required parameter (component id: %1, name: %2), is missing from vehicle. QGroundControl cannot operate with this firmware revision. QGroundControl will now shut down.");
qgcApp()->panicShutdown(panicMessage.arg(componentId).arg(name));
}
Fact* fact = _mapParameterName2Variant[componentId][name].value<Fact*>(); Fact* fact = _mapParameterName2Variant[componentId][name].value<Fact*>();
Q_ASSERT(fact); Q_ASSERT(fact);
return fact; return fact;
......
...@@ -635,3 +635,9 @@ void QGCApplication::_reconnect(void) ...@@ -635,3 +635,9 @@ void QGCApplication::_reconnect(void)
LinkManager::instance()->createConnectedLink(_reconnectLinkConfig); LinkManager::instance()->createConnectedLink(_reconnectLinkConfig);
_reconnectLinkConfig = NULL; _reconnectLinkConfig = NULL;
} }
void QGCApplication::panicShutdown(const QString& panicMessage)
{
QGCMessageBox::critical("Panic Shutdown", panicMessage);
::exit(0);
}
...@@ -98,6 +98,10 @@ public: ...@@ -98,6 +98,10 @@ public:
/// Disconnects the current link and waits for the specified number of seconds before reconnecting. /// Disconnects the current link and waits for the specified number of seconds before reconnecting.
void reconnectAfterWait(int waitSeconds); void reconnectAfterWait(int waitSeconds);
/// Used to shutdown the app if a fatal condition occurs from which it cannot recover
/// @param panicMessage Message to display to user
void panicShutdown(const QString& panicMessage);
public slots: public slots:
/// You can connect to this slot to show an information message box from a different thread. /// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg); void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment