I have created a class CalculationManager which has a public slot process() emitting a signal finished().
void CalculationManager::process()
{
cout << "calc FFT: process()" << endl;
...
emit finished();
}
This is used with a QThread from the gui (calculationManager is a QScopedPointer)
void MainWindow::on_pushButtonStartFFT_clicked()
{
cout << "on_pushButtonStartFFT_clicked()" << endl;
...
calculationManager->moveToThread(thread);
connect(thread, SIGNAL (started()), calculationManager.data(), SLOT (process()));
connect(calculationManager.data(), SIGNAL (finished()), thread, SLOT (quit()));
connect(calculationManager.data(), SIGNAL (finished()), this, SLOT (getResultsAndPlot()));
cout << "FFT thread started." << endl;
thread->start();
}
with a slot for the plots
void MainWindow::getResultsAndPlot()
{
fftAction doShift = static_cast<fftAction>(calculationManager->shiftBeforeFFT());
updatePlotData(ui->qplot1, calculationManager->data(doShift) );
cout << "update plots" << endl;
}
At startup of the gui the function is called. and the output is as expected:
on_pushButtonStartFFT_clicked()
FFT thread started.
calc FFT: process()
update plots
however every further click on the buttons calls process multiple times and getResultsAndPlot() even more often. I have not clue why this happens. How can I debug or solve this ?
on_pushButtonStartFFT_clicked()
FFT thread started.
calc FFT: process()
calc FFT: process()
update plots
update plots
update plots
update plots
on_pushButtonStartFFT_clicked()
FFT thread started.
calc FFT: process()
calc FFT: process()
calc FFT: process()
update plots
update plots
update plots
update plots
update plots
update plots
update plots
update plots
update plots