Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-31 Thread Andrew Potter
You missed the list in your last reply. It is quoted below, and I've
attached the file you sent me as well (table.txt).

On Thu, Jan 31, 2013 at 4:54 PM, Ferdinand Ramirez 
ramirez.ferdin...@yahoo.com wrote:

  Attached is a working program with GtkEntry in the table. If you comment
 out line 21 and uncomment line 20 to use GtkTextView instead of GtkEntry,
 you will encounter the error I mentioned.

 Similarly, if you replace the gtk_widget_show_all on line 65 by
 gtk_widget_show, the error goes away but does not draw the table, only the
 outermost frame. In fact, doing gtk_widget_show for successive levels of
 children works until you reach the GtkTextView level.

 Am I invoking (in lines 73 to 75) the function to create the table in the
 correct manner from the thread? What you see in lines 71 and 72 are
 alternatives to invoking the function but those have identical results as
 well.

 -Ferdinand


I've found that this isn't related to threading, and seems to be a bug in
TextView; my guess is embedding TextViews inside TextViews is somehow a bad
idea.
This error only effects Gtk+-2.0 (at least 2.24.13), and does not effect
Gtk+3.0 (3.6.4)

I have attached a more concise version of the program that produces the
bug. I found that if you delay the show_all on the embedded TextViews to
another g_idle_add, you don't get the error.
I believe the code is valid, so if nobody else has a comment you might want
to file a bug. I don't know if Gtk+2 gets bugfixes anymore though..

The error is:
Gtk-WARNING **: gtktextview.c:4610: somehow some text lines were modified
or scrolling occurred since the last validation of lines on the screen -
may be a text widget bug.
Gtk:ERROR:gtktextview.c:4611:gtk_text_view_paint: code should not be reached

And the backtrace is:
#0  0x0030f9a35ba5 in raise () from /lib64/libc.so.6
#1  0x0030f9a37358 in abort () from /lib64/libc.so.6
#2  0x77775b37 in g_assertion_message () from
/lib64/libglib-2.0.so.0
#3  0x00345001efd5 in gtk_text_view_expose_event () from
/lib64/libgtk-x11-2.0.so.0
#4  0x00344ff4da3c in _gtk_marshal_BOOLEAN__BOXED () from
/lib64/libgtk-x11-2.0.so.0
#5  0x77a3d910 in g_closure_invoke () from
/lib64/libgobject-2.0.so.0
#6  0x77a4ea80 in signal_emit_unlocked_R () from
/lib64/libgobject-2.0.so.0
#7  0x77a568c7 in g_signal_emit_valist () from
/lib64/libgobject-2.0.so.0
#8  0x77a56de2 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#9  0x0034500814be in gtk_widget_event_internal () from
/lib64/libgtk-x11-2.0.so.0
#10 0x00344ff4be80 in gtk_main_do_event () from
/lib64/libgtk-x11-2.0.so.0
#11 0x00344fa4556c in _gdk_window_process_updates_recurse () from
/lib64/libgdk-x11-2.0.so.0
#12 0x00344fa45513 in _gdk_window_process_updates_recurse () from
/lib64/libgdk-x11-2.0.so.0
#13 0x00344fa45513 in _gdk_window_process_updates_recurse () from
/lib64/libgdk-x11-2.0.so.0
#14 0x00344fa45513 in _gdk_window_process_updates_recurse () from
/lib64/libgdk-x11-2.0.so.0
#15 0x00344fa400e7 in gdk_window_process_updates_internal () from
/lib64/libgdk-x11-2.0.so.0
#16 0x00344fa4263e in gdk_window_process_updates () from
/lib64/libgdk-x11-2.0.so.0
#17 0x003450017eb2 in gtk_text_view_value_changed () from
/lib64/libgtk-x11-2.0.so.0
#18 0x003450018346 in get_hadjustment () from /lib64/libgtk-x11-2.0.so.0
#19 0x00345001b140 in gtk_text_view_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#20 0x77a40a9e in g_cclosure_marshal_VOID__BOXEDv () from
/lib64/libgobject-2.0.so.0
#21 0x77a3db0b in _g_closure_invoke_va () from
/lib64/libgobject-2.0.so.0
#22 0x77a563a8 in g_signal_emit_valist () from
/lib64/libgobject-2.0.so.0
#23 0x77a56de2 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#24 0x003450086268 in gtk_widget_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#25 0x00344ff090ae in gtk_frame_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#26 0x77a40a9e in g_cclosure_marshal_VOID__BOXEDv () from
/lib64/libgobject-2.0.so.0
#27 0x77a3db0b in _g_closure_invoke_va () from
/lib64/libgobject-2.0.so.0
#28 0x77a563a8 in g_signal_emit_valist () from
/lib64/libgobject-2.0.so.0
#29 0x77a56de2 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#30 0x003450086268 in gtk_widget_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#31 0x00344ffe595b in gtk_table_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#32 0x77a40a9e in g_cclosure_marshal_VOID__BOXEDv () from
/lib64/libgobject-2.0.so.0
#33 0x77a3db0b in _g_closure_invoke_va () from
/lib64/libgobject-2.0.so.0
#34 0x77a563a8 in g_signal_emit_valist () from
/lib64/libgobject-2.0.so.0
#35 0x77a56de2 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#36 0x003450086268 in gtk_widget_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#37 0x00344ff090ae in gtk_frame_size_allocate () from
/lib64/libgtk-x11-2.0.so.0
#38 0x77a40a9e 

Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Edscott Wilson
The current method for calling gtk_xx instructions is from the main thread
only (i.e., that which owns the main loop context). You can do this by
means of g_main_context_invoke(). Otherwise you must use the deprecated
gdk_threads_enter/gdk_threads_leave mutex method. The deprecated method is
slower.

If you do not do the above, you will get all sort of errors just like the
one you describe.

HTH

2013/1/30 Ferdinand Ramirez ramirez.ferdin...@yahoo.com

 I have encountered a strange error followed by a crash when I add the
 following object to a GtkTextView by creating a child anchor and call
 gtk_widget_show_all.

 The object that is added

 The object that is added to the child anchor is a GtkFrame inside which is
 a GtkTable and each cell of the table contains another GtkFrame each of
 which contains a GtkTextView.

 The error

 This works fine if it is all done from the main program. However, when I
 create the hierarchy described above in another thread and call
 gtk_widget_show_all on the GtkFrame that is added, I get an error in paint
 saying code should not be reached. Before this error, there is a warning
 that the iterator in text view has changed. I am not sure if the warning
 and error are related.

 Source of the error

 I replaced gtk_widget_show_all by gtk_widget_show in a loop going down the
 tree and calling it for each object. The source of the error was the
 gtk_widget_show on the leaf level view objects in the frames contained in
 each cell of the table.

 Situations under which it works

 When the leaf level GtkTextView objects are not part of the hierarchy of
 widgets I create or they are replaced by GtkEntry objects, everything works
 fine. Again, note that it also works fine if I do not have another thread
 and call everything from the main program on startup but I need to have
 another thread as this object will be created during the course of the
 program. I've tried both g_idle_add as well as using the
 gdk_threads_enter/leave pair.

 Any help will be appreciated.

 -Ferdinand
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Edscott Wilson
BTW, g_main_context_invoke() will be erratic if you do not have the main
context loop running. This is common at startup, when you do all sort of
gtk_xx before entering the main loop. Solution: start the loop as soon as
possible in the main thread, and anything else the main thread needs to do,
put in a g_idle function.

2013/1/30 Edscott Wilson edscott.wilson.gar...@gmail.com

 The current method for calling gtk_xx instructions is from the main thread
 only (i.e., that which owns the main loop context). You can do this by
 means of g_main_context_invoke(). Otherwise you must use the deprecated
 gdk_threads_enter/gdk_threads_leave mutex method. The deprecated method is
 slower.

 If you do not do the above, you will get all sort of errors just like the
 one you describe.

 HTH


 2013/1/30 Ferdinand Ramirez ramirez.ferdin...@yahoo.com

 I have encountered a strange error followed by a crash when I add the
 following object to a GtkTextView by creating a child anchor and call
 gtk_widget_show_all.

 The object that is added

 The object that is added to the child anchor is a GtkFrame inside which
 is a GtkTable and each cell of the table contains another GtkFrame each of
 which contains a GtkTextView.

 The error

 This works fine if it is all done from the main program. However, when I
 create the hierarchy described above in another thread and call
 gtk_widget_show_all on the GtkFrame that is added, I get an error in paint
 saying code should not be reached. Before this error, there is a warning
 that the iterator in text view has changed. I am not sure if the warning
 and error are related.

 Source of the error

 I replaced gtk_widget_show_all by gtk_widget_show in a loop going down
 the tree and calling it for each object. The source of the error was the
 gtk_widget_show on the leaf level view objects in the frames contained in
 each cell of the table.

 Situations under which it works

 When the leaf level GtkTextView objects are not part of the hierarchy of
 widgets I create or they are replaced by GtkEntry objects, everything works
 fine. Again, note that it also works fine if I do not have another thread
 and call everything from the main program on startup but I need to have
 another thread as this object will be created during the course of the
 program. I've tried both g_idle_add as well as using the
 gdk_threads_enter/leave pair.

 Any help will be appreciated.

 -Ferdinand
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Ferdinand Ramirez
I used the gdk_threads_enter/gdk_threads_leave pair, but it did not work. It 
does not work even when the whole creation of the hierarchy is within the 
gdk_threads_enter/gdk_threads_leave pair.

I am able to get it to work without using GtkEntry instead of GtkTextView if I 
call the function in main().

However, as I pointed out, it works if I replace the GtkTextView with a 
GtkEntry within each cell of the table. 

-Ferdinand

--- On Wed, 1/30/13, Edscott Wilson edscott.wilson.gar...@gmail.com wrote:

 The current method for calling gtk_xx
 instructions is from the main thread
 only (i.e., that which owns the main loop context). You can
 do this by
 means of g_main_context_invoke(). Otherwise you must use the
 deprecated
 gdk_threads_enter/gdk_threads_leave mutex method. The
 deprecated method is
 slower.
 
 If you do not do the above, you will get all sort of errors
 just like the
 one you describe.
 
 HTH
 
 2013/1/30 Ferdinand Ramirez ramirez.ferdin...@yahoo.com
 
  I have encountered a strange error followed by a crash
 when I add the
  following object to a GtkTextView by creating a child
 anchor and call
  gtk_widget_show_all.
 
  The object that is added
 
  The object that is added to the child anchor is a
 GtkFrame inside which is
  a GtkTable and each cell of the table contains another
 GtkFrame each of
  which contains a GtkTextView.
 
  The error
 
  This works fine if it is all done from the main
 program. However, when I
  create the hierarchy described above in another thread
 and call
  gtk_widget_show_all on the GtkFrame that is added, I
 get an error in paint
  saying code should not be reached. Before this error,
 there is a warning
  that the iterator in text view has changed. I am not
 sure if the warning
  and error are related.
 
  Source of the error
 
  I replaced gtk_widget_show_all by gtk_widget_show in a
 loop going down the
  tree and calling it for each object. The source of the
 error was the
  gtk_widget_show on the leaf level view objects in the
 frames contained in
  each cell of the table.
 
  Situations under which it works
 
  When the leaf level GtkTextView objects are not part of
 the hierarchy of
  widgets I create or they are replaced by GtkEntry
 objects, everything works
  fine. Again, note that it also works fine if I do not
 have another thread
  and call everything from the main program on startup
 but I need to have
  another thread as this object will be created during
 the course of the
  program. I've tried both g_idle_add as well as using
 the
  gdk_threads_enter/leave pair.
 
  Any help will be appreciated.
 
  -Ferdinand
  ___
  gtk-app-devel-list mailing list
  gtk-app-devel-list@gnome.org
  https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Andrew Potter
On Wed, Jan 30, 2013 at 2:17 PM, Ferdinand Ramirez 
ramirez.ferdin...@yahoo.com wrote:

 However, as I pointed out, it works if I replace the GtkTextView with a
 GtkEntry within each cell of the table.
  2013/1/30 Ferdinand Ramirez ramirez.ferdin...@yahoo.com
   This works fine if it is all done from the main program. However, when
 I
   create the hierarchy described above in another thread and call
   gtk_widget_show_all on the GtkFrame that is added, I get an error in
 paint
   saying code should not be reached. Before this error, there is a
 warning
   that the iterator in text view has changed. I am not sure if the
 warning
   and error are related.


If you are getting an iterator warning, you may be trying to use an
invalidated GtkTextIter. Be sure to read
http://developer.gnome.org/gtk3/stable/TextWidget.html

Particularly,Iterators are not valid indefinitely; whenever the buffer is
modified in a way that affects the number of characters in the buffer, all
outstanding iterators become invalid. (Note that deleting 5 characters and
then reinserting 5 still invalidates iterators, though you end up with the
same number of characters you pass through a state with a different number).

Because of this, iterators can't be used to preserve positions across
buffer modifications.

Using an invalid iter is essentially the same as writing data randomly to
memory. The GtkEntry probably works because it doesn't have a
GtkTextBuffer/Iter.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Ferdinand Ramirez
--- On Wed, 1/30/13, Andrew Potter agpot...@gmail.com wrote:
 
 If you are getting an iterator warning, you may be trying to
 use an
 invalidated GtkTextIter. Be sure to read
 http://developer.gnome.org/gtk3/stable/TextWidget.html

I have nothing in there that modifies the buffer. I just create the view and 
add it. In fact, the error comes from the line gtk_widget_show_all. If I 
replace this line with code to traverse the hierarchy and do a gtk_widget_show 
on each object, the error manifests itself only when I get to the GtkTextView 
at the leaf nodes. 

Thanks,
-Ferdinand
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Threads and gtk_widget_show (code should not be reached?)

2013-01-30 Thread Andrew Potter
On Wed, Jan 30, 2013 at 8:11 PM, Ferdinand Ramirez 
ramirez.ferdin...@yahoo.com wrote:

 I have nothing in there that modifies the buffer. I just create the view
 and add it. In fact, the error comes from the line gtk_widget_show_all. If
 I replace this line with code to traverse the hierarchy and do a
 gtk_widget_show on each object, the error manifests itself only when I get
 to the GtkTextView at the leaf nodes.


Unless anyone else has some bright ideas, it would be helpful if you could
post a concise test case.

Thanks,
Andrew
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list