Set parent of QTimer for it to work correctly;
This commit is contained in:
parent
3f0d2a135f
commit
e57406ee6b
@ -11,23 +11,24 @@ Sender::Sender(QObject *parent) : QObject(parent)
|
|||||||
sending=false;
|
sending=false;
|
||||||
readyRecieve = false;
|
readyRecieve = false;
|
||||||
printer = new QSerialPort(this);
|
printer = new QSerialPort(this);
|
||||||
|
sendTimer = new QTimer(this);
|
||||||
|
|
||||||
//Fetch settings
|
//Fetch settings
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
sendTimer.setInterval(settings.value("core/senderinterval", 2).toInt());
|
sendTimer->setInterval(settings.value("core/senderinterval", 2).toInt());
|
||||||
sendingChecksum = settings.value("core/checksums", 0).toBool();
|
sendingChecksum = settings.value("core/checksums", 0).toBool();
|
||||||
|
|
||||||
sendTimer.start();
|
sendTimer->start();
|
||||||
|
|
||||||
connect(printer, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(recievedError(QSerialPort::SerialPortError)));
|
connect(printer, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(recievedError(QSerialPort::SerialPortError)));
|
||||||
connect(printer, &QSerialPort::readyRead, this, &Sender::recievedData);
|
connect(printer, &QSerialPort::readyRead, this, &Sender::recievedData);
|
||||||
connect(&sendTimer, &QTimer::timeout, this, &Sender::sendNext);
|
connect(sendTimer, &QTimer::timeout, this, &Sender::sendNext);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sender::~Sender()
|
Sender::~Sender()
|
||||||
{
|
{
|
||||||
closePort();
|
closePort();
|
||||||
sendTimer.stop();
|
sendTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Mainloop of sending
|
//Mainloop of sending
|
||||||
|
|||||||
2
sender.h
2
sender.h
@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSerialPort *printer;
|
QSerialPort *printer;
|
||||||
|
QTimer *sendTimer;
|
||||||
int currentLine;
|
int currentLine;
|
||||||
int totalLineNum;
|
int totalLineNum;
|
||||||
int baudrate;
|
int baudrate;
|
||||||
@ -29,7 +30,6 @@ protected:
|
|||||||
bool sending;
|
bool sending;
|
||||||
bool readyRecieve;
|
bool readyRecieve;
|
||||||
bool sendingChecksum;
|
bool sendingChecksum;
|
||||||
QTimer sendTimer;
|
|
||||||
QQueue <QString> userCommands;
|
QQueue <QString> userCommands;
|
||||||
QStringList sentCommands;
|
QStringList sentCommands;
|
||||||
QVector <QString> gcode;
|
QVector <QString> gcode;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user