After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 143537 - Delayed formating when applying a tag on text thats being typed
Delayed formating when applying a tag on text thats being typed
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.4.x
Other Linux
: Normal normal
: Medium fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-06-01 19:50 UTC by Gary Kramlich
Modified: 2005-05-27 03:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the proof of concept code.. (1.05 KB, application/x-bzip)
2004-10-06 23:56 UTC, Gary Kramlich
Details

Description Gary Kramlich 2004-06-01 19:50:59 UTC
When gaim released 0.76 with the new WYSIWYG formatting, we've noticed that the
background color doesn't always get applied to the last typed character.  It
happened rather rarely on 2.2.4, generall only when under heavy load, but in
2.4.1 it happens much more often.  The background color is the only formatting
we seem to be having a problem with, and thus are report it to you.  We've only
had this bug reported for users running linux but it may exist on others.  Our
initial report of it can be found here,
http://sourceforge.net/tracker/index.php?func=detail&aid=942086&group_id=235&atid=100235


As mentioned earlier it only happens with background color formatting.  We're
using a g_signal_connect_after for the key press signal, and then appling the tag.
Comment 1 Matthias Clasen 2004-10-06 15:36:43 UTC
How exactly do you set the background color ? Could you please provide a small,
selfcontained testcase which shows the problem ? (A patch against, e.g.
testtext.c would be fine)
Comment 2 Gary Kramlich 2004-10-06 22:51:05 UTC
Will do, I'll have the patch uploaded tonight.
Comment 3 Gary Kramlich 2004-10-06 23:56:09 UTC
Created attachment 32311 [details]
the proof of concept code..
Comment 4 Gary Kramlich 2004-10-06 23:57:30 UTC
I ended up creating a standalone.  The signals being used were a bit off in my
initial report, but the code is pretty easy to follow.  The delayed formatting
on the last character is more often than not noticed on puncuation, but does
happen for other characters as well.
Comment 5 Peter Wainwright 2005-05-22 20:17:35 UTC
Is this the bug?
_gtk_text_btree_tag calls queue_tag_redisplay before it modifies any tags.
Surely this call should be at the end of the function?  As it stands,
the redisplay occurs before any tags are modified, and there is no
redisplay afterwards.  The new tags are only
displayed when a redisplay is called from a timeout (it seems to happen
after about 1 second on my system).
Comment 6 Matthias Clasen 2005-05-23 16:05:50 UTC
No, that just queues a redisplay. The actual redisplay will not happen until the
next idle, ie after _gtk_text_btree_tag has finished.
Comment 7 Peter Wainwright 2005-05-25 19:44:06 UTC
Aha! That's how it is supposed to work.  The problem is that the
layout cache (one_display_cache) gets filled again (using the old
tags) even before queue_tag_redisplay returns.  My program is too
large to post (even if I had the right to do so).  However, the
following stack dump shows where the cache gets refilled, after it has
been invalidated but before any modification to the tags takes place.
I find that placing another queue_tag_redisplay at the end of the
_gtk_text_btree_tag does fix the problem for me.  It also fixes the
testcase previously filed against this bug, so I guess this is the
same problem.

This is using version gtk2-2.4.14-3.fc3 (Fedora Core 3).

  /* Free this if we aren't in a loop */
  if (layout->wrap_loop_count == 0)
    invalidate_cached_style (layout);
    
  g_free (text);
  pango_attr_list_unref (attrs);
    
  layout->one_display_cache = display;              /* <--- gtktextlayout.c:2123 */
    
  if (saw_widget)
    allocate_child_widgets (layout, display);
    
  return display;
}
    
Currently logging to "out.dat".
Logs will be appended to the log file.
Output will be logged and displayed.
  • #0 gtk_text_layout_get_line_display
    at gtktextlayout.c line 2123
  • #1 gtk_text_layout_get_cursor_locations
    at gtktextlayout.c line 2342
  • #2 gtk_text_view_get_cursor_location
    at gtktextview.c line 6727
  • #3 gtk_text_view_update_im_spot_location
    at gtktextview.c line 1788
  • #4 changed_handler
    at gtktextview.c line 3342
  • #5 _gtk_marshal_VOID__INT_INT_INT
    at gtkmarshalers.c line 1567
  • #6 g_closure_invoke
    at gclosure.c line 437
  • #7 signal_emit_unlocked_R
    at gsignal.c line 2478
  • #8 g_signal_emit_valist
    at gsignal.c line 2237
  • #9 g_signal_emit
    at gsignal.c line 2281
  • #10 gtk_text_layout_emit_changed
    at gtktextlayout.c line 603
  • #11 gtk_text_layout_changed
    at gtktextlayout.c line 626
  • #12 redisplay_region
    at gtktextbtree.c line 2616
  • #13 queue_tag_redisplay
    at gtktextbtree.c line 1720
  • #14 _gtk_text_btree_tag
    at gtktextbtree.c line 1768
  • #15 gtk_text_buffer_real_apply_tag
    at gtktextbuffer.c line 2136
  • #16 _gtk_marshal_VOID__OBJECT_BOXED_BOXED
    at gtkmarshalers.c line 1645
  • #17 g_type_class_meta_marshal
    at gclosure.c line 514
  • #18 g_closure_invoke
    at gclosure.c line 437
  • #19 signal_emit_unlocked_R
    at gsignal.c line 2516
  • #20 g_signal_emit_valist
    at gsignal.c line 2237
  • #21 g_signal_emit
    at gsignal.c line 2281
  • #22 gtk_text_buffer_emit_tag
    at gtktextbuffer.c line 2175
  • #23 gtk_text_buffer_apply_tag
    at gtktextbuffer.c line 2211
  • #24 Gtk::TextBuffer::apply_tag
    at textbuffer.cc line 1392
  • #25 UI_Terminal_Dialog::insert_cb
    at ../terminal-dialog.cc line 222
  • #26 sigc::bound_mem_functor3<void, UI_Terminal_Dialog, Gtk::TextIter const&, Glib::ustring const&, int>::operator()
    at mem_fun.h line 1958
  • #27 sigc::adaptor_functor<sigc::bound_mem_functor3<void, UI_Terminal_Dialog, Gtk::TextIter const&, Glib::ustring const&, int> >::operator()<Gtk::TextIter const&, Glib::ustring const&, int const&>
    at adaptor_trait.h line 126
  • #28 sigc::internal::slot_call3<sigc::bound_mem_functor3<void, UI_Terminal_Dialog, Gtk::TextIter const&, Glib::ustring const&, int>, void, Gtk::TextIter const&, Glib::ustring const&, int>::call_it
    at slot.h line 196
  • #29 sigc::slot3<void, Gtk::TextIter const&, Glib::ustring const&, int>::operator()
    at slot.h line 651
  • #30 (anonymous namespace)::TextBuffer_signal_insert_callback
  • #31 _gtk_marshal_VOID__BOXED_STRING_INT
    at gtkmarshalers.c line 1142
  • #32 g_closure_invoke
    at gclosure.c line 437
  • #33 signal_emit_unlocked_R
    at gsignal.c line 2548
  • #34 g_signal_emit_valist
    at gsignal.c line 2237
  • #35 g_signal_emit
    at gsignal.c line 2281
  • #36 gtk_text_buffer_emit_insert
  • #37 gtk_text_buffer_insert_interactive
  • #38 gtk_text_buffer_insert_interactive_at_cursor
  • #39 gtk_text_view_commit_text
  • #40 gtk_text_view_commit_handler
  • #41 g_cclosure_marshal_VOID__STRING
    at gmarshal.c line 496
  • #42 g_closure_invoke
    at gclosure.c line 437
  • #43 signal_emit_unlocked_R
    at gsignal.c line 2478
  • #44 g_signal_emit_valist
    at gsignal.c line 2237
  • #45 g_signal_emit_by_name
    at gsignal.c line 2305
  • #46 gtk_im_multicontext_commit_cb
  • #47 g_cclosure_marshal_VOID__STRING
    at gmarshal.c line 496
  • #48 g_closure_invoke
    at gclosure.c line 437
  • #49 signal_emit_unlocked_R
    at gsignal.c line 2478
  • #50 g_signal_emit_valist
    at gsignal.c line 2237
  • #51 g_signal_emit_by_name
    at gsignal.c line 2305
  • #52 gtk_im_context_simple_commit_char
    at gtkimcontextsimple.c line 1037
  • #53 no_sequence_matches
    at gtkimcontextsimple.c line 1233
  • #54 gtk_im_context_simple_filter_keypress
    at gtkimcontextsimple.c line 1393
  • #55 gtk_im_context_filter_keypress
    at gtkimcontext.c line 317
  • #56 gtk_im_multicontext_filter_keypress
    at gtkimmulticontext.c line 315
  • #57 gtk_im_context_filter_keypress
    at gtkimcontext.c line 317
  • #58 gtk_text_view_key_press_event
    at gtktextview.c line 3820
  • #59 Gtk::Widget_Class::key_press_event_callback
    at widget.cc line 3983
  • #60 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 82
  • #61 g_type_class_meta_marshal
    at gclosure.c line 514
  • #62 g_closure_invoke
    at gclosure.c line 437
  • #63 signal_emit_unlocked_R
    at gsignal.c line 2516
  • #64 g_signal_emit_valist
    at gsignal.c line 2247
  • #65 g_signal_emit
    at gsignal.c line 2281
  • #66 gtk_widget_event_internal
    at gtkwidget.c line 3564
  • #67 gtk_widget_event
    at gtkwidget.c line 3370
  • #68 gtk_window_propagate_key_event
    at gtkwindow.c line 4221
  • #69 gtk_window_key_press_event
    at gtkwindow.c line 4251
  • #70 Gtk::Widget::on_key_press_event
    at widget.cc line 6620
  • #71 Gtk::Widget_Class::key_press_event_callback
    at widget.cc line 3968
  • #72 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 82
  • #73 g_type_class_meta_marshal
    at gclosure.c line 514
  • #74 g_closure_invoke
    at gclosure.c line 437
  • #75 signal_emit_unlocked_R
    at gsignal.c line 2516
  • #76 g_signal_emit_valist
    at gsignal.c line 2247
  • #77 g_signal_emit
    at gsignal.c line 2281
  • #78 gtk_widget_event_internal
    at gtkwidget.c line 3564
  • #79 gtk_widget_event
    at gtkwidget.c line 3370
  • #80 gtk_propagate_event
    at gtkmain.c line 2319
  • #81 gtk_main_do_event
    at gtkmain.c line 1583
  • #82 gdk_event_dispatch
    at gdkevents-x11.c line 2189
  • #83 g_main_dispatch
    at gmain.c line 1942
  • #84 g_main_context_dispatch
    at gmain.c line 2492
  • #85 g_main_context_iterate
    at gmain.c line 2573
  • #86 g_main_loop_run
    at gmain.c line 2777
  • #87 gtk_main
    at gtkmain.c line 1173
  • #88 ui_run
    at ../ui-gtk.cc line 1998
  • #89 main_sub
    at ../femview.cc line 214
  • #90 gh_call3
    from /usr/lib/libguile.so.12
  • #91 scm_boot_guile
    from /usr/lib/libguile.so.12
  • #92 gh_enter
    from /usr/lib/libguile.so.12
  • #93 main
    at ../femview.cc line 267


Peter Wainwright
Comment 8 Matthias Clasen 2005-05-26 19:51:18 UTC
2005-05-26  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtktextbtree.c (_gtk_text_btree_tag): Queue the 
	redisplay after modifying the tag in the btree, otherwise 
	we end up showing the old tags until the next redraw comes 
	around.   (#143537, Gary Kramlich)