Re: Thread safety?



Miles Izzo wrote:
Hi,

I have been getting some strange segfaults, and at the moment I believe
it is something to do with a thread I have running which adds items into
a (derived) TreeStore. Basically, this thread gets a message, which
tells it to add an item into the store. Sometimes (not always), this
operation segfaults, usually when I'm trying to access a row.

Is the TreeStore class (and any related class) thread safe? I am using
pthreads (I'd like to avoid using anything GTK/Glib specific for
threading since, in the future, I'll probably be unplugging gtkmm).

Thanks.


You shouldn't be accessing gtkmm objects from multiple threads. The usual tactic is to use one thread to do all the updates of gtkmm objects, fed by other threads which tell it what it needs to do - usually using Glib::Dispatcher, which helps with the cross-thread communication.

If you access GUI objects from more than one thread you're asking for trouble, because GTK+ and gtkmm are not thread-safe.




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