PDA

View Full Version : QProcess finished slot not firing



doggrant
10th November 2010, 14:09
I have a problem with my QProcess::finished slot not alway being fired.

I have a situation where i spawn about 100 processes, and connect the finished signal of a process to a slot. The slot only gets fired on about 1/2 of the time.

Code looks like this:

int count = 100;
while( count > 0 )
{
QProcess* pProcess = new QProcess();
QStringList Args;
QString App = MyApp;
Args <<MyArgs;

connect( pProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(MySlot(int, QProcess::ExitStatus)) );

pProcess->start( App, Args );

count--;
}

// Now start event loop which waits for processes to end
QEventLoop pEventLoop= new QEventLoop();
pEventLoop->exec();

In My slot, i keep a counter of the number of processes that have completed, and will exit the event loop when all processes have finished.

However i see 100 processes starting (I checked by putting a check on waitForStarted(), which always returns true), but when debugging, it only goes into the slot about 50 times.

any thought why? If a process finishes, before i have exited my while loop that starts the processes, will the signals not fire?

David


}

Added after 1 40 minutes:

Looking in the debug output of visual studio, I have spotted my issue.

QWinEventNotifier: Cannot have more than 62 enabled at one time

Not totally sure what this means, but will be investigating.