PDA

View Full Version : very slowly apps



swiety
19th January 2008, 22:52
I have problem with QProcess. My code:


class Mencoder : public QObject
{
...
private:
QProcess *proc;
};
..

Mencoder::Mencoder( .../* some parameters */, QObject *parent ) : QObject( parent )
{
proc = new QProcess( this );
connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );
connect( proc, SIGNAL( finished(..) ), this, SLOT( on_finished(..) ) );
QStringList arg;
...
proc->start( "mencoder", arg );
}

void Mencoder::update()
{
......
emit newInfo( .... /*some new data for main apps*/ );
}

void Mencoder::on_finished(..)
{
..
proc->close();
deleteLater();
}


Everything works, but i have problem with cpu usage. From system info i have this:


%CPU COMMAND
32 mencoder
40 myApps
23 xorg

Wher's the problem?

nehlsen
20th January 2008, 10:56
i assume mencoder is outputting to fast or is updating a percentage or remaining time or something like that
in this case i would delay emit newInfo(), so it would be emitted max every 50 msecs or something like that

maybe it helps, just a thought

wysota
20th January 2008, 11:05
connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );

You are updating the display every time there is something to read from the process. That's not a very good thing to do, regardless of what you do within update (especially that your paintEvent() is probably not very well designed).

I never had problems with mencoder and cpu usage of the frontend.