Why do you create a timer2 object inside data::event() function (is it a slot?) ?
When you call data::event() again, there will be another "timer2" object and can cause memory leak (if your application doesn't freeze).
I suggest that you declare timer2 as a member of your class, create timer2 object in your constructor, set the interval, then connecting timer2 timeout() signal to your warning_timer2() slot.
data::data(...) : ...
{
....
timer2->setInterval(300000);
timer2->setSingleShot(true);
connect(timer2, SIGNAL(timeout()), this, SLOT(warning_timer2()));
....
}
data::data(...) : ...
{
....
timer2 = new QTimer(this);
timer2->setInterval(300000);
timer2->setSingleShot(true);
connect(timer2, SIGNAL(timeout()), this, SLOT(warning_timer2()));
....
}
To copy to clipboard, switch view to plain text mode
Then, in your data::event()
void data::event ()
{
// Qtimer *timer2 = new QTimer(this);
// QObject::connect( timer2, SIGNAL(timeout()),this,SLOT(warning1_timer2()));
if (((condition1)||(condition2))&&(warning1) ) //Conditions
{
warning1=false;
{
// timer2->start(300000);
timer2->start();
}
}
}
void data::event ()
{
// Qtimer *timer2 = new QTimer(this);
// QObject::connect( timer2, SIGNAL(timeout()),this,SLOT(warning1_timer2()));
if (((condition1)||(condition2))&&(warning1) ) //Conditions
{
warning1=false;
int answer = QMessageBox::warning(this, "Problem detected",QMessageBox::Ok);
if (answer == QMessageBox::Ok)
{
// timer2->start(300000);
timer2->start();
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks