Commit f17a103b authored by DonLakeFlyer's avatar DonLakeFlyer

Q_ASSERT cleanup

parent 59f230ba
...@@ -80,9 +80,10 @@ MavlinkConsoleController::_receiveData(uint8_t device, uint8_t, uint16_t, uint32 ...@@ -80,9 +80,10 @@ MavlinkConsoleController::_receiveData(uint8_t device, uint8_t, uint16_t, uint32
void void
MavlinkConsoleController::_sendSerialData(QByteArray data, bool close) MavlinkConsoleController::_sendSerialData(QByteArray data, bool close)
{ {
Q_ASSERT(_vehicle); if (!_vehicle) {
if (!_vehicle) qWarning() << "Internal error";
return; return;
}
// Send maximum sized chunks until the complete buffer is transmitted // Send maximum sized chunks until the complete buffer is transmitted
while(data.size()) { while(data.size()) {
......
...@@ -37,12 +37,14 @@ void AutoPilotPlugin::_recalcSetupComplete(void) ...@@ -37,12 +37,14 @@ void AutoPilotPlugin::_recalcSetupComplete(void)
foreach(const QVariant componentVariant, vehicleComponents()) { foreach(const QVariant componentVariant, vehicleComponents()) {
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant));
Q_ASSERT(component); if (component) {
if (!component->setupComplete()) { if (!component->setupComplete()) {
newSetupComplete = false; newSetupComplete = false;
break; break;
} }
} else {
qWarning() << "AutoPilotPlugin::_recalcSetupComplete Incorrectly typed VehicleComponent";
}
} }
if (_setupComplete != newSetupComplete) { if (_setupComplete != newSetupComplete) {
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
GenericAutoPilotPlugin::GenericAutoPilotPlugin(Vehicle* vehicle, QObject* parent) : GenericAutoPilotPlugin::GenericAutoPilotPlugin(Vehicle* vehicle, QObject* parent) :
AutoPilotPlugin(vehicle, parent) AutoPilotPlugin(vehicle, parent)
{ {
Q_ASSERT(vehicle); if (!vehicle) {
qWarning() << "Internal error";
}
} }
const QVariantList& GenericAutoPilotPlugin::vehicleComponents(void) const QVariantList& GenericAutoPilotPlugin::vehicleComponents(void)
......
...@@ -15,96 +15,11 @@ ...@@ -15,96 +15,11 @@
#include "QGCQmlWidgetHolder.h" #include "QGCQmlWidgetHolder.h"
#include "ParameterManager.h" #include "ParameterManager.h"
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
struct mavType {
int type;
const char* description;
};
/// @brief Used to translate from MAV_TYPE_* id to user string
static const struct mavType mavTypeInfo[] = {
{ MAV_TYPE_GENERIC, "Generic" },
{ MAV_TYPE_FIXED_WING, "Fixed Wing" },
{ MAV_TYPE_QUADROTOR, "Quadrotor" },
{ MAV_TYPE_COAXIAL, "Coaxial" },
{ MAV_TYPE_HELICOPTER, "Helicopter"},
{ MAV_TYPE_ANTENNA_TRACKER, "Antenna Tracker" },
{ MAV_TYPE_GCS, "Ground Control Station" },
{ MAV_TYPE_AIRSHIP, "Airship" },
{ MAV_TYPE_FREE_BALLOON, "Free Balloon" },
{ MAV_TYPE_ROCKET, "Rocket" },
{ MAV_TYPE_GROUND_ROVER, "Ground Rover" },
{ MAV_TYPE_SURFACE_BOAT, "Boat" },
{ MAV_TYPE_SUBMARINE, "Submarine" },
{ MAV_TYPE_HEXAROTOR, "Hexarotor" },
{ MAV_TYPE_OCTOROTOR, "Octorotor" },
{ MAV_TYPE_TRICOPTER, "Tricopter" },
{ MAV_TYPE_FLAPPING_WING, "Flapping Wing" },
{ MAV_TYPE_KITE, "Kite" },
{ MAV_TYPE_ONBOARD_CONTROLLER, "Onbard companion controller" },
{ MAV_TYPE_VTOL_DUOROTOR, "Two-rotor VTOL" },
{ MAV_TYPE_VTOL_QUADROTOR, "Quad-rotor VTOL" },
{ MAV_TYPE_VTOL_RESERVED1, "Reserved" },
{ MAV_TYPE_VTOL_RESERVED2, "Reserved" },
{ MAV_TYPE_VTOL_RESERVED3, "Reserved" },
{ MAV_TYPE_VTOL_RESERVED4, "Reserved" },
{ MAV_TYPE_VTOL_RESERVED5, "Reserved" },
{ MAV_TYPE_GIMBAL, "Gimbal" },
};
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
#endif
AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent), VehicleComponent(vehicle, autopilot, parent),
_name(tr("Airframe")) _name(tr("Airframe"))
{ {
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
Q_UNUSED(mavTypeInfo); // Keeping this around for later use
// Validate that our mavTypeInfo array hasn't gotten out of sync
qDebug() << cMavTypes << MAV_TYPE_ENUM_END;
Q_ASSERT(cMavTypes == MAV_TYPE_ENUM_END);
static const int mavTypes[] = {
MAV_TYPE_GENERIC,
MAV_TYPE_FIXED_WING,
MAV_TYPE_QUADROTOR,
MAV_TYPE_COAXIAL,
MAV_TYPE_HELICOPTER,
MAV_TYPE_ANTENNA_TRACKER,
MAV_TYPE_GCS,
MAV_TYPE_AIRSHIP,
MAV_TYPE_FREE_BALLOON,
MAV_TYPE_ROCKET,
MAV_TYPE_GROUND_ROVER,
MAV_TYPE_SURFACE_BOAT,
MAV_TYPE_SUBMARINE,
MAV_TYPE_HEXAROTOR,
MAV_TYPE_OCTOROTOR,
MAV_TYPE_TRICOPTER,
MAV_TYPE_FLAPPING_WING,
MAV_TYPE_KITE,
MAV_TYPE_ONBOARD_CONTROLLER,
MAV_TYPE_VTOL_DUOROTOR,
MAV_TYPE_VTOL_QUADROTOR,
MAV_TYPE_VTOL_RESERVED1,
MAV_TYPE_VTOL_RESERVED2,
MAV_TYPE_VTOL_RESERVED3,
MAV_TYPE_VTOL_RESERVED4,
MAV_TYPE_VTOL_RESERVED5,
MAV_TYPE_GIMBAL,
};
Q_UNUSED(mavTypes); // Keeping this around for later use
for (size_t i=0; i<cMavTypes; i++) {
Q_ASSERT(mavTypeInfo[i].type == mavTypes[i]);
}
#endif
} }
QString AirframeComponent::name(void) const QString AirframeComponent::name(void) const
......
...@@ -57,7 +57,9 @@ AirframeComponentController::AirframeComponentController(void) : ...@@ -57,7 +57,9 @@ AirframeComponentController::AirframeComponentController(void) :
Q_CHECK_PTR(pInfo); Q_CHECK_PTR(pInfo);
if (_autostartId == pInfo->autostartId) { if (_autostartId == pInfo->autostartId) {
Q_ASSERT(!autostartFound); if (autostartFound) {
qWarning() << "AirframeComponentController::AirframeComponentController duplicate ids found:" << _autostartId;
}
autostartFound = true; autostartFound = true;
_currentAirframeType = pType->name; _currentAirframeType = pType->name;
_currentVehicleName = pInfo->name; _currentVehicleName = pInfo->name;
......
...@@ -30,7 +30,6 @@ PX4AirframeLoader::PX4AirframeLoader(AutoPilotPlugin* autopilot, UASInterface* u ...@@ -30,7 +30,6 @@ PX4AirframeLoader::PX4AirframeLoader(AutoPilotPlugin* autopilot, UASInterface* u
Q_UNUSED(autopilot); Q_UNUSED(autopilot);
Q_UNUSED(uas); Q_UNUSED(uas);
Q_UNUSED(parent); Q_UNUSED(parent);
Q_ASSERT(uas);
} }
QString PX4AirframeLoader::aiframeMetaDataFile(void) QString PX4AirframeLoader::aiframeMetaDataFile(void)
...@@ -51,7 +50,10 @@ void PX4AirframeLoader::loadAirframeMetaData(void) ...@@ -51,7 +50,10 @@ void PX4AirframeLoader::loadAirframeMetaData(void)
qCDebug(PX4AirframeLoaderLog) << "Loading PX4 airframe fact meta data"; qCDebug(PX4AirframeLoaderLog) << "Loading PX4 airframe fact meta data";
Q_ASSERT(AirframeComponentAirframes::get().count() == 0); if (AirframeComponentAirframes::get().count() != 0) {
qCWarning(PX4AirframeLoaderLog) << "Internal error";
return;
}
QString airframeFilename; QString airframeFilename;
...@@ -67,11 +69,12 @@ void PX4AirframeLoader::loadAirframeMetaData(void) ...@@ -67,11 +69,12 @@ void PX4AirframeLoader::loadAirframeMetaData(void)
qCDebug(PX4AirframeLoaderLog) << "Loading meta data file:" << airframeFilename; qCDebug(PX4AirframeLoaderLog) << "Loading meta data file:" << airframeFilename;
QFile xmlFile(airframeFilename); QFile xmlFile(airframeFilename);
Q_ASSERT(xmlFile.exists()); if (!xmlFile.exists()) {
qCWarning(PX4AirframeLoaderLog) << "Internal error";
return;
}
bool success = xmlFile.open(QIODevice::ReadOnly); bool success = xmlFile.open(QIODevice::ReadOnly);
Q_UNUSED(success);
Q_ASSERT(success);
if (!success) { if (!success) {
qCWarning(PX4AirframeLoaderLog) << "Failed opening airframe XML"; qCWarning(PX4AirframeLoaderLog) << "Failed opening airframe XML";
......
...@@ -41,7 +41,10 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent) ...@@ -41,7 +41,10 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent)
, _tuningComponent(NULL) , _tuningComponent(NULL)
, _mixersComponent(NULL) , _mixersComponent(NULL)
{ {
Q_ASSERT(vehicle); if (!vehicle) {
qWarning() << "Internal error";
return;
}
_airframeFacts = new PX4AirframeLoader(this, _vehicle->uas(), this); _airframeFacts = new PX4AirframeLoader(this, _vehicle->uas(), this);
Q_CHECK_PTR(_airframeFacts); Q_CHECK_PTR(_airframeFacts);
...@@ -57,8 +60,7 @@ PX4AutoPilotPlugin::~PX4AutoPilotPlugin() ...@@ -57,8 +60,7 @@ PX4AutoPilotPlugin::~PX4AutoPilotPlugin()
const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
{ {
if (_components.count() == 0 && !_incorrectParameterVersion) { if (_components.count() == 0 && !_incorrectParameterVersion) {
Q_ASSERT(_vehicle); if (_vehicle) {
if (_vehicle->parameterManager()->parametersReady()) { if (_vehicle->parameterManager()->parametersReady()) {
_airframeComponent = new AirframeComponent(_vehicle, this); _airframeComponent = new AirframeComponent(_vehicle, this);
_airframeComponent->setupTriggerSignals(); _airframeComponent->setupTriggerSignals();
...@@ -120,6 +122,9 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) ...@@ -120,6 +122,9 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
} else { } else {
qWarning() << "Call to vehicleCompenents prior to parametersReady"; qWarning() << "Call to vehicleCompenents prior to parametersReady";
} }
} else {
qWarning() << "Internal error";
}
} }
return _components; return _components;
......
...@@ -73,7 +73,10 @@ bool SensorsComponentController::usingUDPLink(void) ...@@ -73,7 +73,10 @@ bool SensorsComponentController::usingUDPLink(void)
/// Appends the specified text to the status log area in the ui /// Appends the specified text to the status log area in the ui
void SensorsComponentController::_appendStatusLog(const QString& text) void SensorsComponentController::_appendStatusLog(const QString& text)
{ {
Q_ASSERT(_statusLog); if (!_statusLog) {
qWarning() << "Internal error";
return;
}
QVariant returnedValue; QVariant returnedValue;
QVariant varText = text; QVariant varText = text;
...@@ -229,8 +232,11 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in ...@@ -229,8 +232,11 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in
bool ok; bool ok;
int p = percent.toInt(&ok); int p = percent.toInt(&ok);
if (ok) { if (ok) {
Q_ASSERT(_progressBar); if (_progressBar) {
_progressBar->setProperty("value", (float)(p / 100.0)); _progressBar->setProperty("value", (float)(p / 100.0));
} else {
qWarning() << "Internal error";
}
} }
return; return;
} }
...@@ -324,7 +330,7 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in ...@@ -324,7 +330,7 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in
_gyroCalInProgress = true; _gyroCalInProgress = true;
_orientationCalDownSideVisible = true; _orientationCalDownSideVisible = true;
} else { } else {
Q_ASSERT(false); qWarning() << "Unknown calibration message type" << text;
} }
emit orientationCalSidesDoneChanged(); emit orientationCalSidesDoneChanged();
emit orientationCalSidesVisibleChanged(); emit orientationCalSidesVisibleChanged();
......
...@@ -303,11 +303,15 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString ...@@ -303,11 +303,15 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString
_dataMutex.unlock(); _dataMutex.unlock();
Q_ASSERT(_mapParameterName2Variant[componentId].contains(parameterName)); Fact* fact = NULL;
if (_mapParameterName2Variant[componentId].contains(parameterName)) {
Fact* fact = _mapParameterName2Variant[componentId][parameterName].value<Fact*>(); fact = _mapParameterName2Variant[componentId][parameterName].value<Fact*>();
Q_ASSERT(fact); }
if (fact) {
fact->_containerSetRawValue(value); fact->_containerSetRawValue(value);
} else {
qWarning() << "Internal error";
}
if (componentParamsComplete) { if (componentParamsComplete) {
if (componentId == _vehicle->defaultComponentId()) { if (componentId == _vehicle->defaultComponentId()) {
...@@ -352,18 +356,24 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString ...@@ -352,18 +356,24 @@ void ParameterManager::_parameterUpdate(int vehicleId, int componentId, QString
void ParameterManager::_valueUpdated(const QVariant& value) void ParameterManager::_valueUpdated(const QVariant& value)
{ {
Fact* fact = qobject_cast<Fact*>(sender()); Fact* fact = qobject_cast<Fact*>(sender());
Q_ASSERT(fact); if (!fact) {
qWarning() << "Internal error";
return;
}
int componentId = fact->componentId(); int componentId = fact->componentId();
QString name = fact->name(); QString name = fact->name();
_dataMutex.lock(); _dataMutex.lock();
Q_ASSERT(_waitingWriteParamNameMap.contains(componentId)); if (_waitingWriteParamNameMap.contains(componentId)) {
_waitingWriteParamNameMap[componentId].remove(name); // Remove any old entry _waitingWriteParamNameMap[componentId].remove(name); // Remove any old entry
_waitingWriteParamNameMap[componentId][name] = 0; // Add new entry and set retry count _waitingWriteParamNameMap[componentId][name] = 0; // Add new entry and set retry count
_waitingParamTimeoutTimer.start(); _waitingParamTimeoutTimer.start();
_saveRequired = true; _saveRequired = true;
} else {
qWarning() << "Internal error";
}
_dataMutex.unlock(); _dataMutex.unlock();
...@@ -397,7 +407,6 @@ void ParameterManager::refreshAllParameters(uint8_t componentId) ...@@ -397,7 +407,6 @@ void ParameterManager::refreshAllParameters(uint8_t componentId)
_dataMutex.unlock(); _dataMutex.unlock();
MAVLinkProtocol* mavlink = qgcApp()->toolbox()->mavlinkProtocol(); MAVLinkProtocol* mavlink = qgcApp()->toolbox()->mavlinkProtocol();
Q_ASSERT(mavlink);
mavlink_message_t msg; mavlink_message_t msg;
mavlink_msg_param_request_list_pack_chan(mavlink->getSystemId(), mavlink_msg_param_request_list_pack_chan(mavlink->getSystemId(),
...@@ -432,8 +441,6 @@ void ParameterManager::refreshParameter(int componentId, const QString& name) ...@@ -432,8 +441,6 @@ void ParameterManager::refreshParameter(int componentId, const QString& name)
_dataMutex.lock(); _dataMutex.lock();
Q_ASSERT(_waitingReadParamNameMap.contains(componentId));
if (_waitingReadParamNameMap.contains(componentId)) { if (_waitingReadParamNameMap.contains(componentId)) {
QString mappedParamName = _remapParamNameToVersion(name); QString mappedParamName = _remapParamNameToVersion(name);
...@@ -441,6 +448,8 @@ void ParameterManager::refreshParameter(int componentId, const QString& name) ...@@ -441,6 +448,8 @@ void ParameterManager::refreshParameter(int componentId, const QString& name)
_waitingReadParamNameMap[componentId][mappedParamName] = 0; // Add new wait entry and update retry count _waitingReadParamNameMap[componentId][mappedParamName] = 0; // Add new wait entry and update retry count
qCDebug(ParameterManagerLog) << _logVehiclePrefix(componentId) << "restarting _waitingParamTimeout"; qCDebug(ParameterManagerLog) << _logVehiclePrefix(componentId) << "restarting _waitingParamTimeout";
_waitingParamTimeoutTimer.start(); _waitingParamTimeoutTimer.start();
} else {
qWarning() << "Internal error";
} }
_dataMutex.unlock(); _dataMutex.unlock();
......
...@@ -218,22 +218,20 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -218,22 +218,20 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
} }
if (!badMetaData) { if (!badMetaData) {
if (metaData) {
if (elementName == "short_desc") { if (elementName == "short_desc") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
text = text.replace("\n", " "); text = text.replace("\n", " ");
qCDebug(PX4ParameterMetaDataLog) << "Short description:" << text; qCDebug(PX4ParameterMetaDataLog) << "Short description:" << text;
metaData->setShortDescription(text); metaData->setShortDescription(text);
} else if (elementName == "long_desc") { } else if (elementName == "long_desc") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
text = text.replace("\n", " "); text = text.replace("\n", " ");
qCDebug(PX4ParameterMetaDataLog) << "Long description:" << text; qCDebug(PX4ParameterMetaDataLog) << "Long description:" << text;
metaData->setLongDescription(text); metaData->setLongDescription(text);
} else if (elementName == "min") { } else if (elementName == "min") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "Min:" << text; qCDebug(PX4ParameterMetaDataLog) << "Min:" << text;
...@@ -245,7 +243,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -245,7 +243,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
} }
} else if (elementName == "max") { } else if (elementName == "max") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "Max:" << text; qCDebug(PX4ParameterMetaDataLog) << "Max:" << text;
...@@ -257,13 +254,11 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -257,13 +254,11 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
} }
} else if (elementName == "unit") { } else if (elementName == "unit") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "Unit:" << text; qCDebug(PX4ParameterMetaDataLog) << "Unit:" << text;
metaData->setRawUnits(text); metaData->setRawUnits(text);
} else if (elementName == "decimal") { } else if (elementName == "decimal") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "Decimal:" << text; qCDebug(PX4ParameterMetaDataLog) << "Decimal:" << text;
...@@ -276,7 +271,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -276,7 +271,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
} }
} else if (elementName == "reboot_required") { } else if (elementName == "reboot_required") {
Q_ASSERT(metaData);
QString text = xml.readElementText(); QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "RebootRequired:" << text; qCDebug(PX4ParameterMetaDataLog) << "RebootRequired:" << text;
if (text.compare("true", Qt::CaseInsensitive) == 0) { if (text.compare("true", Qt::CaseInsensitive) == 0) {
...@@ -302,7 +296,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -302,7 +296,6 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
<< " error:" << errorString; << " error:" << errorString;
} }
} else if (elementName == "increment") { } else if (elementName == "increment") {
Q_ASSERT(metaData);
double increment; double increment;
bool ok; bool ok;
QString text = xml.readElementText(); QString text = xml.readElementText();
...@@ -349,6 +342,9 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData ...@@ -349,6 +342,9 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
} else { } else {
qCDebug(PX4ParameterMetaDataLog) << "Unknown element in XML: " << elementName; qCDebug(PX4ParameterMetaDataLog) << "Unknown element in XML: " << elementName;
} }
} else {
qWarning() << "Internal error";
}
} }
} }
} else if (xml.isEndElement()) { } else if (xml.isEndElement()) {
......
...@@ -28,8 +28,6 @@ GPSManager::~GPSManager() ...@@ -28,8 +28,6 @@ GPSManager::~GPSManager()
void GPSManager::connectGPS(const QString& device) void GPSManager::connectGPS(const QString& device)
{ {
Q_ASSERT(_toolbox);
RTKSettings* rtkSettings = qgcApp()->toolbox()->settingsManager()->rtkSettings(); RTKSettings* rtkSettings = qgcApp()->toolbox()->settingsManager()->rtkSettings();
cleanup(); cleanup();
......
...@@ -176,7 +176,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -176,7 +176,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
, _toolbox(NULL) , _toolbox(NULL)
, _bluetoothAvailable(false) , _bluetoothAvailable(false)
{ {
Q_ASSERT(_app == NULL);
_app = this; _app = this;
// This prevents usage of QQuickWidget to fail since it doesn't support native widget siblings // This prevents usage of QQuickWidget to fail since it doesn't support native widget siblings
...@@ -473,7 +472,6 @@ void QGCApplication::clearDeleteAllSettingsNextBoot(void) ...@@ -473,7 +472,6 @@ void QGCApplication::clearDeleteAllSettingsNextBoot(void)
/// @brief Returns the QGCApplication object singleton. /// @brief Returns the QGCApplication object singleton.
QGCApplication* qgcApp(void) QGCApplication* qgcApp(void)
{ {
Q_ASSERT(QGCApplication::_app);
return QGCApplication::_app; return QGCApplication::_app;
} }
...@@ -612,8 +610,7 @@ void QGCApplication::reportMissingParameter(int componentId, const QString& name ...@@ -612,8 +610,7 @@ void QGCApplication::reportMissingParameter(int componentId, const QString& name
/// Called when the delay timer fires to show the missing parameters warning /// Called when the delay timer fires to show the missing parameters warning
void QGCApplication::_missingParamsDisplay(void) void QGCApplication::_missingParamsDisplay(void)
{ {
Q_ASSERT(_missingParams.count()); if (_missingParams.count()) {
QString params; QString params;
foreach (const QString &name, _missingParams) { foreach (const QString &name, _missingParams) {
if (params.isEmpty()) { if (params.isEmpty()) {
...@@ -625,6 +622,7 @@ void QGCApplication::_missingParamsDisplay(void) ...@@ -625,6 +622,7 @@ void QGCApplication::_missingParamsDisplay(void)
_missingParams.clear(); _missingParams.clear();
showMessage(QString("Parameters are missing from firmware. You may be running a version of firmware QGC does not work correctly with or your firmware has a bug in it. Missing params: %1").arg(params)); showMessage(QString("Parameters are missing from firmware. You may be running a version of firmware QGC does not work correctly with or your firmware has a bug in it. Missing params: %1").arg(params));
}
} }
QObject* QGCApplication::_rootQmlObject() QObject* QGCApplication::_rootQmlObject()
......
...@@ -110,8 +110,8 @@ void QGCFileDownload::_downloadFinished(void) ...@@ -110,8 +110,8 @@ void QGCFileDownload::_downloadFinished(void)
// Download file location is in user attribute // Download file location is in user attribute
QString downloadFilename = reply->request().attribute(QNetworkRequest::User).toString(); QString downloadFilename = reply->request().attribute(QNetworkRequest::User).toString();
Q_ASSERT(!downloadFilename.isEmpty());
if (!downloadFilename.isEmpty()) {
// Store downloaded file in download location // Store downloaded file in download location
QFile file(downloadFilename); QFile file(downloadFilename);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
...@@ -123,6 +123,11 @@ void QGCFileDownload::_downloadFinished(void) ...@@ -123,6 +123,11 @@ void QGCFileDownload::_downloadFinished(void)
file.close(); file.close();
emit downloadFinished(_originalRemoteFile, downloadFilename); emit downloadFinished(_originalRemoteFile, downloadFilename);
} else {
QString errorMsg = "Internal error";
qWarning() << errorMsg;
emit error(errorMsg);
}
} }
/// @brief Called when an error occurs during download /// @brief Called when an error occurs during download
......
...@@ -39,8 +39,9 @@ QGCPalette::QGCPalette(QObject* parent) : ...@@ -39,8 +39,9 @@ QGCPalette::QGCPalette(QObject* parent) :
QGCPalette::~QGCPalette() QGCPalette::~QGCPalette()
{ {
bool fSuccess = _paletteObjects.removeOne(this); bool fSuccess = _paletteObjects.removeOne(this);
Q_ASSERT(fSuccess); if (!fSuccess) {
Q_UNUSED(fSuccess); qWarning() << "Internal error";
}
} }
void QGCPalette::_buildMap(void) void QGCPalette::_buildMap(void)
......
...@@ -126,7 +126,9 @@ QString QGCQFileDialog::getSaveFileName( ...@@ -126,7 +126,9 @@ QString QGCQFileDialog::getSaveFileName(
defaultSuffixCopy = _getFirstExtensionInFilter(filter); defaultSuffixCopy = _getFirstExtensionInFilter(filter);
} }
//-- If this is set to strict, we have to have a default extension //-- If this is set to strict, we have to have a default extension
Q_ASSERT(defaultSuffixCopy.isEmpty() == false); if (defaultSuffixCopy.isEmpty()) {
qWarning() << "Internal error";
}
//-- Forcefully append our desired extension //-- Forcefully append our desired extension
result += "."; result += ".";
result += defaultSuffixCopy; result += defaultSuffixCopy;
...@@ -197,9 +199,13 @@ void QGCQFileDialog::_validate(Options& options) ...@@ -197,9 +199,13 @@ void QGCQFileDialog::_validate(Options& options)
Q_UNUSED(options) Q_UNUSED(options)
// You can't use QGCQFileDialog if QGCApplication is not created yet. // You can't use QGCQFileDialog if QGCApplication is not created yet.
Q_ASSERT(qgcApp()); if (!qgcApp()) {
qWarning() << "Internal error";
return;
}
Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCQFileDialog can only be called from main thread"); if (QThread::currentThread() != qgcApp()->thread()) {
if (MainWindow::instance()) { qWarning() << "Threading issue: QGCQFileDialog can only be called from main thread";
return;
} }
} }
...@@ -89,8 +89,9 @@ QStringList ParameterEditorController::searchParametersForComponent(int componen ...@@ -89,8 +89,9 @@ QStringList ParameterEditorController::searchParametersForComponent(int componen
void ParameterEditorController::clearRCToParam(void) void ParameterEditorController::clearRCToParam(void)
{ {
Q_ASSERT(_uas); if (_uas) {
_uas->unsetRCToParameterMap(); _uas->unsetRCToParameterMap();
}
} }
void ParameterEditorController::saveToFile(const QString& filename) void ParameterEditorController::saveToFile(const QString& filename)
...@@ -147,9 +148,10 @@ void ParameterEditorController::setRCToParam(const QString& paramName) ...@@ -147,9 +148,10 @@ void ParameterEditorController::setRCToParam(const QString& paramName)
#ifdef __mobile__ #ifdef __mobile__
Q_UNUSED(paramName) Q_UNUSED(paramName)
#else #else
Q_ASSERT(_uas); if (_uas) {
QGCMapRCToParamDialog * d = new QGCMapRCToParamDialog(paramName, _uas, qgcApp()->toolbox()->multiVehicleManager(), MainWindow::instance()); QGCMapRCToParamDialog * d = new QGCMapRCToParamDialog(paramName, _uas, qgcApp()->toolbox()->multiVehicleManager(), MainWindow::instance());
d->exec(); d->exec();
}
#endif #endif
} }
......
...@@ -498,7 +498,7 @@ MAVLinkLogManager::uploadLog() ...@@ -498,7 +498,7 @@ MAVLinkLogManager::uploadLog()
} }
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
_currentLogfile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i)); _currentLogfile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(_currentLogfile); if (_currentLogfile) {
if(_currentLogfile->selected()) { if(_currentLogfile->selected()) {
_currentLogfile->setSelected(false); _currentLogfile->setSelected(false);
if(!_currentLogfile->uploaded() && !_emailAddress.isEmpty() && !_uploadURL.isEmpty()) { if(!_currentLogfile->uploaded() && !_emailAddress.isEmpty() && !_uploadURL.isEmpty()) {
...@@ -510,6 +510,9 @@ MAVLinkLogManager::uploadLog() ...@@ -510,6 +510,9 @@ MAVLinkLogManager::uploadLog()
return; return;
} }
} }
} else {
qWarning() << "Internal error";
}
} }
_currentLogfile = NULL; _currentLogfile = NULL;
emit uploadingChanged(); emit uploadingChanged();
...@@ -541,10 +544,13 @@ MAVLinkLogManager::_getFirstSelected() ...@@ -541,10 +544,13 @@ MAVLinkLogManager::_getFirstSelected()
{ {
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
MAVLinkLogFiles* f = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i)); MAVLinkLogFiles* f = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(f); if (f) {
if(f->selected()) { if(f->selected()) {
return i; return i;
} }
} else {
qWarning() << "Internal error";
}
} }
return -1; return -1;
} }
...@@ -590,10 +596,13 @@ MAVLinkLogManager::cancelUpload() ...@@ -590,10 +596,13 @@ MAVLinkLogManager::cancelUpload()
{ {
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
MAVLinkLogFiles* pLogFile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i)); MAVLinkLogFiles* pLogFile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(pLogFile); if (pLogFile) {
if(pLogFile->selected() && pLogFile != _currentLogfile) { if(pLogFile->selected() && pLogFile != _currentLogfile) {
pLogFile->setSelected(false); pLogFile->setSelected(false);
} }
} else {
qWarning() << "Internal error";
}
} }
if(_currentLogfile) { if(_currentLogfile) {
emit abortUpload(); emit abortUpload();
......
...@@ -20,8 +20,9 @@ VehicleComponent::VehicleComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, ...@@ -20,8 +20,9 @@ VehicleComponent::VehicleComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot,
_vehicle(vehicle), _vehicle(vehicle),
_autopilot(autopilot) _autopilot(autopilot)
{ {
Q_ASSERT(vehicle); if (!vehicle || !autopilot) {
Q_ASSERT(autopilot); qWarning() << "Internal error";
}
} }
VehicleComponent::~VehicleComponent() VehicleComponent::~VehicleComponent()
...@@ -31,19 +32,23 @@ VehicleComponent::~VehicleComponent() ...@@ -31,19 +32,23 @@ VehicleComponent::~VehicleComponent()
void VehicleComponent::addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent) void VehicleComponent::addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent)
{ {
Q_ASSERT(context); if (context) {
// FIXME: We own this object now, need to delete somewhere // FIXME: We own this object now, need to delete somewhere
QQmlComponent component(context->engine(), QUrl::fromUserInput("qrc:/qml/VehicleComponentSummaryButton.qml")); QQmlComponent component(context->engine(), QUrl::fromUserInput("qrc:/qml/VehicleComponentSummaryButton.qml"));
if (component.status() == QQmlComponent::Error) { if (component.status() == QQmlComponent::Error) {
qDebug() << component.errors(); qWarning() << component.errors();
Q_ASSERT(false); } else {
}
QQuickItem* item = qobject_cast<QQuickItem*>(component.create(context)); QQuickItem* item = qobject_cast<QQuickItem*>(component.create(context));
Q_ASSERT(item); if (item) {
item->setParentItem(parent); item->setParentItem(parent);
item->setProperty("vehicleComponent", QVariant::fromValue(this)); item->setProperty("vehicleComponent", QVariant::fromValue(this));
} else {
qWarning() << "Internal error";
}
}
} else {
qWarning() << "Internal error";
}
} }
void VehicleComponent::setupTriggerSignals(void) void VehicleComponent::setupTriggerSignals(void)
......
...@@ -33,11 +33,11 @@ void ViewWidgetController::_vehicleAvailable(bool available) ...@@ -33,11 +33,11 @@ void ViewWidgetController::_vehicleAvailable(bool available)
_uas = vehicle->uas(); _uas = vehicle->uas();
_autopilot = vehicle->autopilotPlugin(); _autopilot = vehicle->autopilotPlugin();
Q_ASSERT(_autopilot);
emit pluginConnected(QVariant::fromValue(_autopilot)); emit pluginConnected(QVariant::fromValue(_autopilot));
} }
} }
Q_INVOKABLE void ViewWidgetController::checkForVehicle(void)
void ViewWidgetController::checkForVehicle(void)
{ {
_vehicleAvailable(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()); _vehicleAvailable(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle());
} }
...@@ -152,7 +152,9 @@ qint64 LinkInterface::_getCurrentDataRate(int index, const qint64 dataWriteTimes ...@@ -152,7 +152,9 @@ qint64 LinkInterface::_getCurrentDataRate(int index, const qint64 dataWriteTimes
/// Sets the mavlink channel to use for this link /// Sets the mavlink channel to use for this link
void LinkInterface::_setMavlinkChannel(uint8_t channel) void LinkInterface::_setMavlinkChannel(uint8_t channel)
{ {
Q_ASSERT(!_mavlinkChannelSet); if (_mavlinkChannelSet) {
qWarning() << "Mavlink channel set multiple times";
}
_mavlinkChannelSet = true; _mavlinkChannelSet = true;
_mavlinkChannel = channel; _mavlinkChannel = channel;
} }
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#endif #endif
#ifndef __mobile__ #ifndef __mobile__
#include "GPSManager.h" #include "GPSManager.h"
#endif #endif
QGC_LOGGING_CATEGORY(LinkManagerLog, "LinkManagerLog") QGC_LOGGING_CATEGORY(LinkManagerLog, "LinkManagerLog")
...@@ -150,12 +150,16 @@ LinkInterface* LinkManager::createConnectedLink(SharedLinkConfigurationPointer& ...@@ -150,12 +150,16 @@ LinkInterface* LinkManager::createConnectedLink(SharedLinkConfigurationPointer&
LinkInterface* LinkManager::createConnectedLink(const QString& name) LinkInterface* LinkManager::createConnectedLink(const QString& name)
{ {
Q_ASSERT(name.isEmpty() == false); if (name.isEmpty()) {
qWarning() << "Internal error";
} else {
for(int i = 0; i < _sharedConfigurations.count(); i++) { for(int i = 0; i < _sharedConfigurations.count(); i++) {
SharedLinkConfigurationPointer& conf = _sharedConfigurations[i]; SharedLinkConfigurationPointer& conf = _sharedConfigurations[i];
if (conf->name() == name) if (conf->name() == name) {
return createConnectedLink(conf); return createConnectedLink(conf);
} }
}
}
return NULL; return NULL;
} }
...@@ -219,13 +223,15 @@ void LinkManager::disconnectAll(void) ...@@ -219,13 +223,15 @@ void LinkManager::disconnectAll(void)
bool LinkManager::connectLink(LinkInterface* link) bool LinkManager::connectLink(LinkInterface* link)
{ {
Q_ASSERT(link); if (link) {
if (_connectionsSuspendedMsg()) { if (_connectionsSuspendedMsg()) {
return false; return false;
} }
return link->_connect(); return link->_connect();
} else {
qWarning() << "Internal error";
return false;
}
} }
void LinkManager::disconnectLink(LinkInterface* link) void LinkManager::disconnectLink(LinkInterface* link)
...@@ -301,7 +307,6 @@ void LinkManager::setConnectionsSuspended(QString reason) ...@@ -301,7 +307,6 @@ void LinkManager::setConnectionsSuspended(QString reason)
{ {
_connectionsSuspended = true; _connectionsSuspended = true;
_connectionsSuspendedReason = reason; _connectionsSuspendedReason = reason;
Q_ASSERT(!reason.isEmpty());
} }
void LinkManager::_linkConnected(void) void LinkManager::_linkConnected(void)
...@@ -647,7 +652,9 @@ QStringList LinkManager::linkTypeStrings(void) const ...@@ -647,7 +652,9 @@ QStringList LinkManager::linkTypeStrings(void) const
#ifndef __mobile__ #ifndef __mobile__
list += "Log Replay"; list += "Log Replay";
#endif #endif
Q_ASSERT(list.size() == (int)LinkConfiguration::TypeLast); if (list.size() != (int)LinkConfiguration::TypeLast) {
qWarning() << "Internal error";
}
} }
return list; return list;
} }
...@@ -697,8 +704,7 @@ QStringList LinkManager::serialBaudRates(void) ...@@ -697,8 +704,7 @@ QStringList LinkManager::serialBaudRates(void)
bool LinkManager::endConfigurationEditing(LinkConfiguration* config, LinkConfiguration* editedConfig) bool LinkManager::endConfigurationEditing(LinkConfiguration* config, LinkConfiguration* editedConfig)
{ {
Q_ASSERT(config != NULL); if (config && editedConfig) {
Q_ASSERT(editedConfig != NULL);
_fixUnnamed(editedConfig); _fixUnnamed(editedConfig);
config->copyFrom(editedConfig); config->copyFrom(editedConfig);
saveLinkConfigurationList(); saveLinkConfigurationList();
...@@ -706,15 +712,21 @@ bool LinkManager::endConfigurationEditing(LinkConfiguration* config, LinkConfigu ...@@ -706,15 +712,21 @@ bool LinkManager::endConfigurationEditing(LinkConfiguration* config, LinkConfigu
config->updateSettings(); config->updateSettings();
// Discard temporary duplicate // Discard temporary duplicate
delete editedConfig; delete editedConfig;
} else {
qWarning() << "Internal error";
}
return true; return true;
} }
bool LinkManager::endCreateConfiguration(LinkConfiguration* config) bool LinkManager::endCreateConfiguration(LinkConfiguration* config)
{ {
Q_ASSERT(config != NULL); if (config) {
_fixUnnamed(config); _fixUnnamed(config);
addConfiguration(config); addConfiguration(config);
saveLinkConfigurationList(); saveLinkConfigurationList();
} else {
qWarning() << "Internal error";
}
return true; return true;
} }
...@@ -729,18 +741,22 @@ LinkConfiguration* LinkManager::createConfiguration(int type, const QString& nam ...@@ -729,18 +741,22 @@ LinkConfiguration* LinkManager::createConfiguration(int type, const QString& nam
LinkConfiguration* LinkManager::startConfigurationEditing(LinkConfiguration* config) LinkConfiguration* LinkManager::startConfigurationEditing(LinkConfiguration* config)
{ {
Q_ASSERT(config != NULL); if (config) {
#ifndef NO_SERIAL_LINK #ifndef NO_SERIAL_LINK
if(config->type() == LinkConfiguration::TypeSerial) if(config->type() == LinkConfiguration::TypeSerial)
_updateSerialPorts(); _updateSerialPorts();
#endif #endif
return LinkConfiguration::duplicateSettings(config); return LinkConfiguration::duplicateSettings(config);
} else {
qWarning() << "Internal error";
return NULL;
}
} }
void LinkManager::_fixUnnamed(LinkConfiguration* config) void LinkManager::_fixUnnamed(LinkConfiguration* config)
{ {
Q_ASSERT(config != NULL); if (config) {
//-- Check for "Unnamed" //-- Check for "Unnamed"
if (config->name() == "Unnamed") { if (config->name() == "Unnamed") {
switch(config->type()) { switch(config->type()) {
...@@ -798,11 +814,14 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config) ...@@ -798,11 +814,14 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config)
break; break;
} }
} }
} else {
qWarning() << "Internal error";
}
} }
void LinkManager::removeConfiguration(LinkConfiguration* config) void LinkManager::removeConfiguration(LinkConfiguration* config)
{ {
Q_ASSERT(config != NULL); if (config) {
LinkInterface* iface = config->link(); LinkInterface* iface = config->link();
if(iface) { if(iface) {
disconnectLink(iface); disconnectLink(iface);
...@@ -810,6 +829,9 @@ void LinkManager::removeConfiguration(LinkConfiguration* config) ...@@ -810,6 +829,9 @@ void LinkManager::removeConfiguration(LinkConfiguration* config)
_removeConfiguration(config); _removeConfiguration(config);
saveLinkConfigurationList(); saveLinkConfigurationList();
} else {
qWarning() << "Internal error";
}
} }
bool LinkManager::isAutoconnectLink(LinkInterface* link) bool LinkManager::isAutoconnectLink(LinkInterface* link)
......
...@@ -35,8 +35,11 @@ void LogReplayLinkConfiguration::copyFrom(LinkConfiguration *source) ...@@ -35,8 +35,11 @@ void LogReplayLinkConfiguration::copyFrom(LinkConfiguration *source)
{ {
LinkConfiguration::copyFrom(source); LinkConfiguration::copyFrom(source);
LogReplayLinkConfiguration* ssource = dynamic_cast<LogReplayLinkConfiguration*>(source); LogReplayLinkConfiguration* ssource = dynamic_cast<LogReplayLinkConfiguration*>(source);
Q_ASSERT(ssource != NULL); if (ssource) {
_logFilename = ssource->logFilename(); _logFilename = ssource->logFilename();
} else {
qWarning() << "Internal error";
}
} }
void LogReplayLinkConfiguration::saveSettings(QSettings& settings, const QString& root) void LogReplayLinkConfiguration::saveSettings(QSettings& settings, const QString& root)
...@@ -70,7 +73,9 @@ LogReplayLink::LogReplayLink(SharedLinkConfigurationPointer& config) ...@@ -70,7 +73,9 @@ LogReplayLink::LogReplayLink(SharedLinkConfigurationPointer& config)
, _connected(false) , _connected(false)
, _replayAccelerationFactor(1.0f) , _replayAccelerationFactor(1.0f)
{ {
Q_ASSERT(_logReplayConfig); if (!_logReplayConfig) {
qWarning() << "Internal error";
}
_readTickTimer.moveToThread(this); _readTickTimer.moveToThread(this);
......
...@@ -38,7 +38,10 @@ SerialLink::SerialLink(SharedLinkConfigurationPointer& config) ...@@ -38,7 +38,10 @@ SerialLink::SerialLink(SharedLinkConfigurationPointer& config)
, _reqReset(false) , _reqReset(false)
, _serialConfig(qobject_cast<SerialConfiguration*>(config.data())) , _serialConfig(qobject_cast<SerialConfiguration*>(config.data()))
{ {
Q_ASSERT(_serialConfig); if (!_serialConfig) {
qWarning() << "Internal error";
return;
}
qCDebug(SerialLinkLog) << "Create SerialLink " << _serialConfig->portName() << _serialConfig->baud() << _serialConfig->flowControl() qCDebug(SerialLinkLog) << "Create SerialLink " << _serialConfig->portName() << _serialConfig->baud() << _serialConfig->flowControl()
<< _serialConfig->parity() << _serialConfig->dataBits() << _serialConfig->stopBits(); << _serialConfig->parity() << _serialConfig->dataBits() << _serialConfig->stopBits();
...@@ -378,7 +381,7 @@ void SerialConfiguration::copyFrom(LinkConfiguration *source) ...@@ -378,7 +381,7 @@ void SerialConfiguration::copyFrom(LinkConfiguration *source)
{ {
LinkConfiguration::copyFrom(source); LinkConfiguration::copyFrom(source);
SerialConfiguration* ssource = dynamic_cast<SerialConfiguration*>(source); SerialConfiguration* ssource = dynamic_cast<SerialConfiguration*>(source);
Q_ASSERT(ssource != NULL); if (ssource) {
_baud = ssource->baud(); _baud = ssource->baud();
_flowControl = ssource->flowControl(); _flowControl = ssource->flowControl();
_parity = ssource->parity(); _parity = ssource->parity();
...@@ -387,6 +390,9 @@ void SerialConfiguration::copyFrom(LinkConfiguration *source) ...@@ -387,6 +390,9 @@ void SerialConfiguration::copyFrom(LinkConfiguration *source)
_portName = ssource->portName(); _portName = ssource->portName();
_portDisplayName = ssource->portDisplayName(); _portDisplayName = ssource->portDisplayName();
_usbDirect = ssource->_usbDirect; _usbDirect = ssource->_usbDirect;
} else {
qWarning() << "Internal error";
}
} }
void SerialConfiguration::updateSettings() void SerialConfiguration::updateSettings()
......
...@@ -67,15 +67,17 @@ static QString get_ip_address(const QString& address) ...@@ -67,15 +67,17 @@ static QString get_ip_address(const QString& address)
UDPLink::UDPLink(SharedLinkConfigurationPointer& config) UDPLink::UDPLink(SharedLinkConfigurationPointer& config)
: LinkInterface(config) : LinkInterface(config)
#if defined(QGC_ZEROCONF_ENABLED) #if defined(QGC_ZEROCONF_ENABLED)
, _dnssServiceRef(NULL) , _dnssServiceRef(NULL)
#endif #endif
, _running(false) , _running(false)
, _socket(NULL) , _socket(NULL)
, _udpConfig(qobject_cast<UDPConfiguration*>(config.data())) , _udpConfig(qobject_cast<UDPConfiguration*>(config.data()))
, _connectState(false) , _connectState(false)
{ {
Q_ASSERT(_udpConfig); if (!_udpConfig) {
qWarning() << "Internal error";
}
moveToThread(this); moveToThread(this);
} }
...@@ -347,7 +349,7 @@ void UDPConfiguration::copyFrom(LinkConfiguration *source) ...@@ -347,7 +349,7 @@ void UDPConfiguration::copyFrom(LinkConfiguration *source)
{ {
LinkConfiguration::copyFrom(source); LinkConfiguration::copyFrom(source);
UDPConfiguration* usource = dynamic_cast<UDPConfiguration*>(source); UDPConfiguration* usource = dynamic_cast<UDPConfiguration*>(source);
Q_ASSERT(usource != NULL); if (usource) {
_localPort = usource->localPort(); _localPort = usource->localPort();
_hosts.clear(); _hosts.clear();
QString host; QString host;
...@@ -357,6 +359,9 @@ void UDPConfiguration::copyFrom(LinkConfiguration *source) ...@@ -357,6 +359,9 @@ void UDPConfiguration::copyFrom(LinkConfiguration *source)
addHost(host, port); addHost(host, port);
} while(usource->nextHost(host, port)); } while(usource->nextHost(host, port));
} }
} else {
qWarning() << "Internal error";
}
} }
/** /**
......
...@@ -92,10 +92,7 @@ static MainWindow* _instance = NULL; ///< @brief MainWindow singleton ...@@ -92,10 +92,7 @@ static MainWindow* _instance = NULL; ///< @brief MainWindow singleton
MainWindow* MainWindow::_create() MainWindow* MainWindow::_create()
{ {
Q_ASSERT(_instance == NULL);
new MainWindow(); new MainWindow();
// _instance is set in constructor
Q_ASSERT(_instance);
return _instance; return _instance;
} }
...@@ -118,7 +115,6 @@ MainWindow::MainWindow() ...@@ -118,7 +115,6 @@ MainWindow::MainWindow()
, _mainQmlWidgetHolder(NULL) , _mainQmlWidgetHolder(NULL)
, _forceClose(false) , _forceClose(false)
{ {
Q_ASSERT(_instance == NULL);
_instance = this; _instance = this;
//-- Load fonts //-- Load fonts
...@@ -337,7 +333,7 @@ void MainWindow::_showDockWidget(const QString& name, bool show) ...@@ -337,7 +333,7 @@ void MainWindow::_showDockWidget(const QString& name, bool show)
// Create the inner widget if we need to // Create the inner widget if we need to
if (!_mapName2DockWidget.contains(name)) { if (!_mapName2DockWidget.contains(name)) {
if(!_createInnerDockWidget(name)) { if(!_createInnerDockWidget(name)) {
qWarning() << "Trying to load non existing widget:" << name; qWarning() << "Trying to load non existent widget:" << name;
return; return;
} }
} }
......
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