removed can_bus and change slot from pointer to object as the object might have been deallocated when the slot is activated

This commit is contained in:
canpadawan
2016-06-08 11:34:15 +02:00
parent e9f4dac3a1
commit 9ae3d4f979
2 changed files with 4 additions and 97 deletions
+1 -69
View File
@@ -1,74 +1,6 @@
#include "canconnection.h"
CAN_Bus::CAN_Bus()
{
speed = 250000;
listenOnly = false;
singleWire = false;
active = false;
connection = NULL;
busNum = 0;
}
void CAN_Bus::setSpeed(int newSpeed)
{
speed = newSpeed;
}
void CAN_Bus::setListenOnly(bool mode)
{
listenOnly = mode;
}
void CAN_Bus::setSingleWire(bool mode)
{
singleWire = mode;
}
void CAN_Bus::setEnabled(bool mode)
{
active = mode;
}
void CAN_Bus::setConnection(CANConnection *conn)
{
connection = conn;
}
void CAN_Bus::setBusNum(int num)
{
busNum = num;
}
int CAN_Bus::getSpeed()
{
return speed;
}
int CAN_Bus::getBusNum()
{
return busNum;
}
bool CAN_Bus::isListenOnly()
{
return listenOnly;
}
bool CAN_Bus::isSingleWire()
{
return singleWire;
}
bool CAN_Bus::isActive()
{
return active;
}
CANConnection* CAN_Bus::getConnection()
{
return connection;
}
CANConnection::CANConnection(CANFrameModel *pModel, int base)
{
@@ -127,7 +59,7 @@ void CANConnection::startFrameCapture(int bus)
}
void CANConnection::updateBusSettings(CAN_Bus *bus)
void CANConnection::updateBusSettings(CANBus bus)
{
}
+3 -28
View File
@@ -4,35 +4,9 @@
#include <Qt>
#include <QObject>
#include "can_structs.h"
#include "canbus.h"
#include "canframemodel.h"
class CANConnection;
class CAN_Bus
{
public:
CAN_Bus();
int busNum;
int speed;
bool listenOnly;
bool singleWire;
bool active; //is this bus turned on?
CANConnection *connection;
void setSpeed(int); // new speed
void setListenOnly(bool); //bool for whether to only listen
void setSingleWire(bool); //bool for whether to use single wire mode
void setEnabled(bool); //whether this bus should be enabled or not.
void setConnection(CANConnection *);
void setBusNum(int);
int getSpeed();
int getBusNum();
bool isListenOnly();
bool isSingleWire();
bool isActive();
CANConnection *getConnection();
};
//Gentle reminder, CANConnection objects run in their own thread (each one, different thread)
//so, for the love of God, do not try to access them directly.
@@ -70,7 +44,8 @@ public slots:
virtual void updatePortName(QString); //string version of the port to connect to. This base doesnt know a thing about this value
virtual void stopFrameCapture(int); //pass bus number
virtual void startFrameCapture(int); //pass bus number. Only if stopped. Defaults to started anyway
virtual void updateBusSettings(CAN_Bus *bus); //reference to the bus that changed.
/* this is not safe to use pointers with QueuedConnection */
virtual void updateBusSettings(CANBus); //reference to the bus that changed.
protected:
bool quit;