Re: [gtkmm] Re: pthreads with gtk/gtkmm



Enrico Costanza wrote:

klaus triendl wrote:

To be precise, the function that I am trying to put in a thread is:

void *test(void *arg){
 Args *a = (Args *) arg;
 Gtk::Main kit(a->argc, a->argv);
 gdk_rgb_init(); //initialize gtk rgb, used to display images
 MyCameraFramework myCameraFramework(640, 480, false);
 kit.run();
 cout << "run returned" << endl;
 return NULL;
}


i would say that you reconsider your application/thread model.

don't know whether the approach to put the gui-mainthread in another thread
works but it is not a good idea.
better create Gtk::Main in main() and then create a separate thread in
MyCameraFramework or also in main(); then use Glib::Dispatcher as a means to
communication with the gui-objects if you use gtkmm-2.x

--
triendl klaus
Thanks for your reply.

I am using gtkmm1.2: do I have to upgrade to 2.2?

If I create a separate thread in MyCameraFramework, shall I pass to the thread a reference to this, so that then I can contol GUI objects with Dispatcher (or simila)?

What I had in mind was the java multi-thread system, that seems a lot simpler than pthreads. My problem can be easily described as a producer-consumer problem. The producer uses gtkmm to display its status and for some Adjustments; the consumer produces sounds according to the producer results.


Regards,
Enrico

I forgot to mention also that I am using <pthread.h> rather than anything related to glib, gthread. Is this fine??

Thanks again,
Enrico




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