1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

GCS-Fixes some crashes on hw disconnection.

This commit is contained in:
PT_Dreamer 2012-07-09 00:15:21 +01:00
parent 452e3d6a22
commit 4c9327da7e
3 changed files with 11 additions and 9 deletions

View File

@ -389,7 +389,7 @@ void Telemetry::processObjectQueue()
if ( ( objInfo.event != EV_UNPACKED ) && ( ( objInfo.event != EV_UPDATED_PERIODIC ) || ( updateMode != UAVObject::UPDATEMODE_THROTTLED ) ) )
{
UAVObject::Metadata metadata = objInfo.obj->getMetadata();
ObjectTransactionInfo *transInfo = new ObjectTransactionInfo();
ObjectTransactionInfo *transInfo = new ObjectTransactionInfo(this);
transInfo->obj = objInfo.obj;
transInfo->allInstances = objInfo.allInstances;
transInfo->retriesRemaining = MAX_RETRIES;
@ -402,9 +402,9 @@ void Telemetry::processObjectQueue()
{
transInfo->objRequest = true;
}
transInfo->telem = this;
// Insert the transaction into the transaction map.
transMap.insert(objInfo.obj->getObjID(), transInfo);
transInfo->telem = this;
// Insert the transaction into the transaction map.
transMap.insert(objInfo.obj->getObjID(), transInfo);
processObjectTransaction(transInfo);
}
@ -559,7 +559,7 @@ void Telemetry::newInstance(UAVObject* obj)
registerObject(obj);
}
ObjectTransactionInfo::ObjectTransactionInfo()
ObjectTransactionInfo::ObjectTransactionInfo(QObject* parent):QObject(parent)
{
obj = 0;
allInstances = false;
@ -582,6 +582,6 @@ ObjectTransactionInfo::~ObjectTransactionInfo()
void ObjectTransactionInfo::timeout()
{
if (telem)
if (!telem.isNull())
telem->transactionTimeout(this);
}

View File

@ -41,14 +41,14 @@ class ObjectTransactionInfo: public QObject {
Q_OBJECT
public:
ObjectTransactionInfo();
ObjectTransactionInfo(QObject * parent);
~ObjectTransactionInfo();
UAVObject* obj;
bool allInstances;
bool objRequest;
qint32 retriesRemaining;
bool acked;
class Telemetry* telem;
QPointer<class Telemetry>telem;
QTimer* timer;
private slots:
void timeout();

View File

@ -159,6 +159,8 @@ void UAVTalk::cancelTransaction(UAVObject* obj)
{
QMutexLocker locker(mutex);
quint32 objId = obj->getObjID();
if(io.isNull())
return;
QMap<quint32, Transaction*>::iterator itr = transMap.find(objId);
if ( itr != transMap.end() )
{
@ -827,7 +829,7 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance
txBuffer[dataOffset+length] = updateCRC(0, txBuffer, dataOffset + length);
// Send buffer, check that the transmit backlog does not grow above limit
if (io && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE )
if (!io.isNull() && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE )
{
io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
}