Commit 7411b3c3 authored by Don Gagne's avatar Don Gagne

Merge pull request #1506 from DonLakeFlyer/ParamCrashOut

Exit app immediately if missing required paramter
parents 14d9765c a546d9a6
......@@ -93,10 +93,10 @@ void AutoPilotPluginManager::_uasDeleted(UASInterface* uas)
int uasId = uas->getUASID();
Q_ASSERT(uasId != 0);
Q_ASSERT(_pluginMap.contains(autopilotType));
Q_ASSERT(_pluginMap[autopilotType].contains(uasId));
delete _pluginMap[autopilotType][uasId];
_pluginMap[autopilotType].remove(uasId);
if (_pluginMap.contains(autopilotType) && _pluginMap[autopilotType].contains(uasId)) {
delete _pluginMap[autopilotType][uasId];
_pluginMap[autopilotType].remove(uasId);
}
}
AutoPilotPlugin* AutoPilotPluginManager::getInstanceForAutoPilotPlugin(UASInterface* uas)
......
......@@ -27,6 +27,8 @@
#include "FactBinder.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h"
#include "QGCApplication.h"
#include <QDebug>
FactBinder::FactBinder(void) :
......@@ -83,8 +85,8 @@ void FactBinder::setName(const QString& name)
emit nameChanged();
emit metaDataChanged();
} else {
qWarning() << "FAILED BINDING PARAM" << name << ": PARAM DOES NOT EXIST ON SYSTEM!";
Q_ASSERT(false);
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(parsedName));
}
}
}
......
......@@ -27,6 +27,7 @@
#include "ParameterLoader.h"
#include "QGCApplication.h"
#include "QGCLoggingCategory.h"
#include "QGCApplication.h"
#include <QFile>
#include <QDebug>
......@@ -268,8 +269,12 @@ bool ParameterLoader::parameterExists(int componentId, const QString& name)
Fact* ParameterLoader::getFact(int componentId, const QString& name)
{
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*>();
Q_ASSERT(fact);
return fact;
......
......@@ -635,3 +635,9 @@ void QGCApplication::_reconnect(void)
LinkManager::instance()->createConnectedLink(_reconnectLinkConfig);
_reconnectLinkConfig = NULL;
}
void QGCApplication::panicShutdown(const QString& panicMessage)
{
QGCMessageBox::critical("Panic Shutdown", panicMessage);
::exit(0);
}
......@@ -98,6 +98,10 @@ public:
/// Disconnects the current link and waits for the specified number of seconds before reconnecting.
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:
/// You can connect to this slot to show an information message box from a different thread.
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