[gtkmm] Re: pthreads with gtk/gtkmm



>>there is absolutely no problem mixing pthreads, C++, GTK+ and
>>gtkmm. you need to understand multithreaded programming, which is not
>>trivial, and it is best if you stick to the model that only one thread
>>ever calls gtkmm/GTK+/GDK/Xlib functions. the latest gtkmm has a nice
>>class (called Dispatcher, i forget which namespace) that makes this
>>rather easy to do.
>>
>>but i repeat: there are no problems doing this (i've been doing it for years)
>.
>>
>>--p
>>  
>>
>Thank you for your reply.
>
>I am not deliberately doing any inter-thread communication.

you mentioned, i think, making GTK/GDK/Xlib calls in different
threads. that by itself is enough to be the source of your problems if
you have not surrounded every such call with the relevant thread
mutex (gdk_threads_{enter,leave}()).

>What I have done at this stage is take the main function of my 
>application and put it in a pthread.
>Still I get that segmentation fault that I do not understand.
>
>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;
>}
>
>As far as I can see, the problems might come from the fact that some of 
>the gtkmm constructors (such as the kit constructor or the Gtk::Window - 
>from which myCameraFramework is derived) involve other threads.

they do not involve other threads unless you make them.

--p



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