LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2005, 12:29 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
problems with synchronization of threads in updating a text buffer in gtk2.0


Hi all,
I am working on developing a gui for my application which runs many posix threads. These threads will try to update the text view by adding text. this is how the i have written the code

gtk_text_buffer_get_bounds(buffer,&start,&end);
gtk_text_buffer_insert(buffer,&end,printbuffer,strlen(printbuffer));

Some times i get

Gtk-CRITICAL **: gtk_text_layout_real_invalidate: assertion `layout->wrap_loop_count == 0' failed

Gtk-WARNING **: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators

After some searching i found that this due to some threading issue with gtk. I also used g_thread_init () and gdk_threads_init() , gdk_thread_leave and gdk_thread_enter as specified in the following link,

http://mail.gnome.org/archives/gtk-a.../msg00086.html

this works but this slows down my updation of the MMI quite considerably which i dont want.

Is there any other alternative for this or if some one has worked on the following lines before and has got it to work please let me know. Cos this is very urgent.

Regards
S.Suresh Stephen
 
Old 12-21-2005, 04:47 PM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
i just read the first line
Quote:
I am working on developing a gui for my application which runs many posix threads. These threads will try to update the text view by adding text.
I would rethink your app and only have one thread for the gui. Having more than this for the graphic interface is a recipe for a disaster.

Last edited by dmail; 12-21-2005 at 04:49 PM.
 
Old 12-29-2005, 11:31 PM   #3
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi dmail,
Sorry for the delay in reply was sick. Wat u told me is right and this i know, it is always not a good programming practice to have multiple threads altering a GUI. I also want a way to fix that. Any way i had also found a solution for this i have made use of the call g_idle_add() and this seems to have fixed my issue , no crashes so far.
Thanks for ur reply any way.

Regards,

S.Suresh Stephen
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
updating a line of text on a php web server mrobertson Programming 9 06-15-2005 09:43 AM
ntp synchronization problems ricky_ds Linux - Networking 1 10-13-2004 10:22 AM
email synchronization (not file synchronization) Moebius Linux - Software 6 10-05-2004 05:31 AM
Firebird 0.7 w/ GTK2 - no text in some flash applets Locura Slackware 8 11-27-2003 07:27 PM
GTK2 problems nocturnal Linux - Software 1 05-11-2003 08:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration