Re: A problem about programming with gtk+ in multiprocess.



"Jean-Christophe Berthon" <jean-christophe berthon cgey com> writes: 
> So in the case the child is doing computation while the father show progress
> information and allow the user to stop the computation. I'm modifying the
> memory of Gtk --> updating the value of progress bar and some labels and
> status bar. Then is the memory duplicated?
> If yes, how can I remove it fom the child, else (if no) then it is OK :-)

 - Semantically and conceptually, all memory is copied in the 
   child
 - In practice, the kernel doesn't copy it until you try to use 
   it, as an optimization
 - You could free memory in the child, but that would force the kernel 
   to actually copy the memory, which would be slow; also, it would 
   be done via gtk_widget_destroy(), which is not allowed, 
   because GTK will crash

The rule to follow is:
 - You may not touch GTK widgets created in the parent in the child,
   in any way, it will not work

You can't use a child process to directly update a progress bar widget
in the parent. End of story. It won't work. You have to do something
like have the child send progress information to the parent via a
pipe.

A good book for this kind of thing is "Beginning Linux Programming"
from Wrox Press.

Havoc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]