Re: Text widget crashing



Tim Janik <timj@gtk.org> wrote:

> if at all (and the reasonings you give actually sound very plausible
> to me) you should redraw the cursor as:
> 
> void
> gtk_text_thaw (GtkText *text)
> {
>   g_return_if_fail (text != NULL);
>   g_return_if_fail (GTK_IS_TEXT (text));
> 
>   if (text->freeze_count)
>     if (!(--text->freeze_count) && GTK_WIDGET_REALIZED (text))
>       {
>         recompute_geometry (text);
>         gtk_widget_queue_draw (GTK_WIDGET (text));
> +       draw_cursor (text, FALSE);
>       }
> }
> 
> to correctly honour the freeze count.

This does not work unless you also do

void
gtk_text_freeze (GtkText *text)
{
  g_return_if_fail (text != NULL);
  g_return_if_fail (GTK_IS_TEXT (text));

-  text->freeze_count++;  
+  if (!(text->freeze_count++) && GTK_WIDGET_REALIZED (text))
+    undraw_cursor (text, FALSE);
}


However, it seems to me that draw/undraw_cursor() do their own level
accounting and so my initial patch amounts to nearly the same, with
less modification.

I felt more comfortable providing the simple patch which surely does
the job. Even with just the above few additions, I am uncertain if the
cursor is cleared and drawn correctly in all circumstances. Of course,
this is a result of me not knowing the source that well.

But one way or the other - as long as it goes into 1.2.7 I will be
happy:-).

-- 
Mvh. Anders



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