Browse Source

Merge pull request #1506 from DonLakeFlyer/ParamCrashOut

Exit app immediately if missing required paramter
QGC4.4
Don Gagne 10 years ago
parent
commit
7411b3c35a
  1. 4
      src/AutoPilotPlugins/AutoPilotPluginManager.cc
  2. 6
      src/FactSystem/FactBinder.cc
  3. 9
      src/FactSystem/ParameterLoader.cc
  4. 6
      src/QGCApplication.cc
  5. 4
      src/QGCApplication.h

4
src/AutoPilotPlugins/AutoPilotPluginManager.cc

@ -93,11 +93,11 @@ void AutoPilotPluginManager::_uasDeleted(UASInterface* uas) @@ -93,11 +93,11 @@ void AutoPilotPluginManager::_uasDeleted(UASInterface* uas)
int uasId = uas->getUASID();
Q_ASSERT(uasId != 0);
Q_ASSERT(_pluginMap.contains(autopilotType));
Q_ASSERT(_pluginMap[autopilotType].contains(uasId));
if (_pluginMap.contains(autopilotType) && _pluginMap[autopilotType].contains(uasId)) {
delete _pluginMap[autopilotType][uasId];
_pluginMap[autopilotType].remove(uasId);
}
}
AutoPilotPlugin* AutoPilotPluginManager::getInstanceForAutoPilotPlugin(UASInterface* uas)
{

6
src/FactSystem/FactBinder.cc

@ -27,6 +27,8 @@ @@ -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) @@ -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));
}
}
}

9
src/FactSystem/ParameterLoader.cc

@ -27,6 +27,7 @@ @@ -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) @@ -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;

6
src/QGCApplication.cc

@ -635,3 +635,9 @@ void QGCApplication::_reconnect(void) @@ -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);
}

4
src/QGCApplication.h

@ -98,6 +98,10 @@ public: @@ -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);

Loading…
Cancel
Save