Set parent of QTimer for it to work correctly;

This commit is contained in:
NeoTheFox 2015-03-14 01:55:55 +03:00
parent 3f0d2a135f
commit e57406ee6b
2 changed files with 6 additions and 5 deletions

View File

@ -11,23 +11,24 @@ Sender::Sender(QObject *parent) : QObject(parent)
sending=false;
readyRecieve = false;
printer = new QSerialPort(this);
sendTimer = new QTimer(this);
//Fetch 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();
sendTimer.start();
sendTimer->start();
connect(printer, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(recievedError(QSerialPort::SerialPortError)));
connect(printer, &QSerialPort::readyRead, this, &Sender::recievedData);
connect(&sendTimer, &QTimer::timeout, this, &Sender::sendNext);
connect(sendTimer, &QTimer::timeout, this, &Sender::sendNext);
}
Sender::~Sender()
{
closePort();
sendTimer.stop();
sendTimer->stop();
}
//Mainloop of sending

View File

@ -22,6 +22,7 @@ public:
protected:
QSerialPort *printer;
QTimer *sendTimer;
int currentLine;
int totalLineNum;
int baudrate;
@ -29,7 +30,6 @@ protected:
bool sending;
bool readyRecieve;
bool sendingChecksum;
QTimer sendTimer;
QQueue <QString> userCommands;
QStringList sentCommands;
QVector <QString> gcode;