Timer instance connection delete
-
Hi
I have the following to have a cert periodically updated:
QTimer *SSLupdateTimer = new QTimer(this); connect(SSLupdateTimer, SIGNAL(timeout()), this, SLOT(UpdateSSLcertificate())); SSLupdateTimer->setInterval(CERT_UPDATE_INTERVAL); SSLupdateTimer->start();
Usually this is called once. If this is called again, this will create a second timer, right? And it will also create another connection.
How do I best catch this? How do I detect if there already is an instance and then kill it as well as the connection before creating a new one?
... or am I somehow wrong?
Thanks -
Hi,
Why not keep that timer as a private member of the class, null_ptr by default and check whether it's initialized when calling the function that contains that code ?
-
Why do you create the timer instance on the heap?
And if you want to do it like this, then put the pointer in your class and initialize the pointer with 0.
Then each time your code is executed you check whether the pointer is null, if it is then you execute your code if not you do nothing.
Do you delete the timer instance somewhere?