updating a GtkTextBuffer from both the app and thread
- From: kosh <evil_kosh_uk yahoo co uk>
- To: GtkList <gtk-list gnome org>
- Subject: updating a GtkTextBuffer from both the app and thread
- Date: 27 May 2003 00:03:31 +0100
Hi,
I'm writing an app which has a debug feature, it gives you information
written to an ostream object, just like cout that will get written to a
GtkTextBuffer object. The application has X number of threads running,
one thread for each download being processed. the debug feature
essentially is a "function call" trace of each function and associated
data, along with any other data you wish to output. I'd like to display
this information in a nice neat text window rather than have a console
show all this data and have a nasty console always present. It just
makes more sense to me.
My problem is that I update the textbuffer from within the application
(what I mean is outside of any threads, the application CREATES the
threads which run within the app, if you get that). Then also the
threads can execute functions which also output "function call" trace
data to the same textbuffer.
Now, I've read from sources on the internet that you should call
gdk_threads_enter()/leave() around blocks of GTK+ code which executes in
the threads you have in your application. To do with GTK+ gaining a
global lock when it updates the interface, you need to do the same.
I've made a macro, ENTER_THREADS(), LEAVE_THREADS(), which wrap up a
std::cout << reference_count << std::endl; in the same call, just to
keep the code clean, I've heard that you cannot call gdk_threads_enter
twice in a row, but I've not really come across that problem before, I
just thought I would be safe.
Now, everything seems to work fine, but sometimes calling
gdk_threads_enter() causes my application to just "stall". It usually
happens when I try to execute a menu option whilst having the debug text
window open. But no threads are executing, it still stalls and you
can't wait until it passes, it's locked up and you can only kill -9 the
app.
Anyone got any thoughts? Anyone who wants to take a look at my code can
do so, but since I aint got anywhere to put the source, you'll have to
get an email of it. But I'd prefer to just get help, rather than waste
your time looking through my code!
thanks
--
kosh <evil_kosh_uk yahoo co uk>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]