Rendering bug after GTK+2.10.1 with GtkTreeViewCellRenderer



Hi,

I'm working on a project which uses a subclassed GtkTextView as a custom
cell renderer for displaying and editing multi-line text in a tree view
column.

I didn't write the code, but it appears plausible. It simply implements
the GtkCellEditable interface.

Since GTK+-2.10.1, there is a rendering bug, where the widget to edit a
cell gets allocated zero height, and of course then doesn't display very
usefully. 

(Version number was inferred from the tags in the CVS viewer at this
change:

http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtktreeview.c?r1=1.562&r2=1.563

"""
2006-07-18  Kristian Rietveld  <kris imendio com>

        Fix for #335012, reported by Matteo Nastasi.

        * gtk/gtktreeview.c (gtk_tree_view_real_start_editing): if the
        requested space of the editable is smaller than the cell area,
        put it up above the middle of the cell area.
"""
)

Since this change, as the tree view handles the initialisation of the
custom renderer, it asks the size of the widget. GtkTextView
(incorrectly?) returns zero height and width, which causes me to get a
zero/one(?) pixel high cell renderer when editing the cell. (Displaying
the cell works fine).


Could there be a "race" between the gtktreeview wanting to know the size
before realising / displaying the widget, and the gtktextview not
knowing its size
until afterwards?


Breakpoint 2, gtk_text_view_size_request (widget=0x82fba20, 
    requisition=0xbfcf4960) at gtktextview.c:2764
2764    in gtktextview.c
(gdb) print *(GtkTextView *)0x82fba20
$1 = {parent_instance = {widget = {object = {parent_instance = {
          g_type_instance = {g_class = 0x8313c78}, ref_count = 1, 
          qdata = 0x8370910}, flags = 2100738}, private_flags = 13312, 
      state = 0 '\0', saved_state = 0 '\0', name = 0x0, style =
0x8146098, 
      requisition = {width = 0, height = 0}, allocation = {x = -1, y =
-1, 
        width = 1, height = 1}, window = 0x0, parent = 0x0}, 
    focus_child = 0x0, border_width = 0, need_resize = 0, resize_mode =
0, 
    reallocate_redraws = 0, has_focus_chain = 0}, layout = 0x8311720, 
  buffer = 0x83758d0, selection_drag_handler = 0, scroll_timeout = 0, 
  pixels_above_lines = 0, pixels_below_lines = 0, pixels_inside_wrap =
0, 
  wrap_mode = GTK_WRAP_NONE, justify = GTK_JUSTIFY_LEFT, left_margin =
0, 
  right_margin = 0, indent = 0, tabs = 0x0, editable = 1, overwrite_mode
= 0, 
  cursor_visible = 1, need_im_reset = 0, accepts_tab = 1, width_changed
= 0, 
  onscreen_validated = 0, mouse_cursor_obscured = 0, text_window =
0x8371a80, 
  left_window = 0x0, right_window = 0x0, top_window = 0x0, 
  bottom_window = 0x0, hadjustment = 0x0, vadjustment = 0x0, xoffset =
0, 
  yoffset = 0, width = 0, height = 0, virtual_cursor_x = -1, 
  virtual_cursor_y = -1, first_para_mark = 0x836e270, first_para_pixels
= 0, 
  dnd_mark = 0x836e420, blink_timeout = 0, first_validate_idle = 160, 
  incremental_validate_idle = 161, im_context = 0x8351660, popup_menu =
0x0, 
  drag_start_x = -1, drag_start_y = -1, children = 0x0, pending_scroll =
0x0, 
  pending_place_cursor_button = 0}


It looks like the widget is fairly uninitialised at this point:

requisition = {width = 0, height = 0}, allocation = {x = -1, y = -1, 
        width = 1, height = 1}, window = 0x0, parent = 0x0}, 
    focus_child = 0x0, border_width = 0, need_resize = 0, resize_mode =
0, 
    reallocate_redraws = 0, has_focus_chain = 0}

admittedly, gtk_text_view_size_request actually sets some of these
rather than reading them, but I'm unsure whether the layout member
actually has any sensible value at this point.

It contains:

(gdb) print *((GtkTextView *)0x82fba20)->layout
$4 = {parent_instance = {g_type_instance = {g_class = 0x82fd748}, 
    ref_count = 2, qdata = 0x0}, screen_width = 0, width = 0, height =
0, 
  buffer = 0x83758d0, default_style = 0x0, ltr_context = 0x0, 
  rtl_context = 0x0, one_style_cache = 0x0, one_display_cache = 0x0, 
  wrap_loop_count = 0, cursor_visible = 0, cursor_direction = 0, 
  keyboard_direction = 0, preedit_string = 0x0, preedit_attrs = 0x0, 
  preedit_len = 0, preedit_cursor = 0}

Since I'm not particularly familiar with the (perhaps necessarily)
complicated way which GTK handles widget allocation, I'm not sure
exactly what is going on here.

Any thoughts?

Is it a bug in GTK, or simply a new "feature" which needs working around
since bug #335012 was fixed?

Should I take this to the gtk-devel-list?

Regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173




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