[Interest] Finished signal from QProcess!

Lata Agrawal lata.agrawal at enrouteinc.com
Wed Feb 29 11:30:34 CET 2012


On 29 February 2012 14:11, Mandeep Sandhu <mandeepsandhu.chd at gmail.com>wrote:

> >
> > One more thing, in C2 (the main process, I have called a class which
> starts
> > an infinite loop and a.exec is called after that which essentially means
> > a.exec() is never called. Is this the reason why I am not getting
> finished
> > signal? Code is shown below:
>
> Yes it is!!! The event loop needs to be running for it process events
> and since you're never executing a.exec() it never gets started.
>
>
I'm not sure why the C1 process is being listed as defunct. Can you
> provide us with a compilable example which shows the problem?
>
> This would happen, if lets say we start a child process using QProcess
from main application and don't start the event loop of main application.
Now when child process stops, since main apps event loop is not running, it
doesn't receive the finished hence no one deletes the child process object
on heap. Now if you run ps in terminal, you will see child process as
defunct.

> >
> >
> > int main(int argc, char *argv[])
> > {
> >     Class1 downloadMngr;
> >     downloadMngr.startDownload(); //This starts an infinite loop which
> waits
> > for items to be added to queue
> >
> >     return a.exec();  //So this is probably never called.
>
> Correct.
>
> Now when I know the problem, I think I am nearing solving this. Thanks for
your help.


> > }
> >
> > How can I start eventloop in main() while having the functionality in
> > Class1.
>
> What is this functionality of C1? It's not clear from your mail. Looks
> like you're writing some sort of an application updater (which
> downloads a new app and writes it?)?
>
> Can you explain a little more of what you're attempting. Do you need 2
> processes in the first place? Can't it be done with a single process
> i.e your main app itself?
> I  am trying to create a pre-emptive queue in which each item is a
> download of different priority. In code above Class1 is a downloadmanager
> which runs a forever loop and using mutex and waitcondition I wait for new
> upload being added to queue. Now if a higher priority download is added,
> current ongoing update has to be stopped. I used QProcess instead of a
> thread, to start the download because killing a QProcess is neater. Now
> problem is when an ongoing download ends i.e. its process ends,
> downlaodmanager should receive a finished signal so that it can process
> another download in queue.
>
> Hope I have made myself clear. If something is not clear, I can explain
> again. How do you think I can run forever loop and also start event loop in
> main process? Or if you can think of a better way of doing this.
>
> Regards,
> Lata
>

> Regards,
> -mandeep
>
> >
> > Regards,
> > Lata
> >>
> >>
> >> HTH,
> >> -mandeep
> >>
> >> > Regards,
> >> > Lata
> >> >
> >> >
> >> > --
> >> >
> >> >
> >> > Lata Agrawal
> >> > Senior Developer
> >> > 9699750643
> >> > En Route Media Pvt. Ltd.
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > Interest mailing list
> >> > Interest at qt-project.org
> >> > http://lists.qt-project.org/mailman/listinfo/interest
> >> >
> >
> >
> >
> >
> > --
> >
> >
> > Lata Agrawal
> > Senior Developer
> > 9699750643
> > En Route Media Pvt. Ltd.
> >
> >
>



-- 
*

*Lata Agrawal
Senior Developer
9699750643
En Route Media Pvt. Ltd.
*                                 *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120229/468f3a66/attachment.html>


More information about the Interest mailing list