I'm trying to use QThreadPool on a QRunnable-base class The code is the following
void Window::on_randomBtn_clicked()
{
QString value;
_pool.start(_randomizer);
_pool.waitForDone();
value = _randomizer->value();
ui->RVal->setText(value);
_red.setRgb(value.toInt(), 0, 0);
_pool.start(_randomizer);
_pool.waitForDone();
value = _randomizer->value();
ui->GVal->setText(value);
_green.setRgb(0, value.toInt(), 0);
...
In the above code _pool
is an instance of QThreadPool
and _randomizer
an instance of a class Randomizer
which extends QRunnable
.
The run
method of the Randomizer
is just a oneliner producing random numbers
I can't understand why but what happens is just a SIGABRT signal received by the application after calling the second time the _pool.start(_randomizer)
I've also tried to instantiate two different Randomizer
objects but the same behavior holds.
Could you help me explaining why?