Re: gtk_notebook_map bug



Hi Owen,

On Mon, Jan 24, 2000 at 12:18:20PM -0500, Owen Taylor wrote:
> 
> Damon Chaplin <damon@karuna.freeserve.co.uk> writes:
> 
> > gtk_notebook_map () doesn't check if the tab label is visible before
> > mapping it (GTK+ 1.2.6):
> > 
> > 	  if (page->tab_label && 
> > 	      GTK_WIDGET_VISIBLE (page->child) && 
> > 	      !GTK_WIDGET_MAPPED (page->tab_label))
> > 	    gtk_widget_map (page->tab_label);
> > 
> > This results in warnings when a notebook is used with tabs hidden:
> > 
> >    Gtk-CRITICAL **: file gtkwidget.c: line 1584 (gtk_widget_map):
> >            assertion `GTK_WIDGET_VISIBLE (widget) == TRUE' failed.
> > 
> > 
> > Maybe this would be better (though I'm not sure how GtkNotebook fits
> > together):
> > 
> > 	  if (page->tab_label && 
> > 	      GTK_WIDGET_VISIBLE (page->child) && 
> >               GTK_WIDGET_VISIBLE (page->tab_label) &&
> > 	      !GTK_WIDGET_MAPPED (page->tab_label))
> > 	    gtk_widget_map (page->tab_label);
> 
> Do you have an example that could be used to determine the code path
> that was causing this warning?
> 
> The original code is pretty clearly bogus but I can't actually
> reproduce the warning.

Generate and show a notebook with labels and try something like :

  gtk_notebook_set_show_tabs (notebook, FALSE);
  gtk_widget_hide (GTK_WIDGET(notebook));
  gtk_widget_show (GTK_WIDGET(notebook));

> There are various things going on here:
> 
>  a) There doesn't seem to be the proper check here for notebook->show_tabs
>  b) The notebook shows and hides the tab labels as well mapping/unmapping 
>     them.
> 
> So, a safe rewrite for this section of code would look a bit like:
> 
>       children = notebook->children;
> 
>       while (children)
> 	{
> 	  page = children->data;
> 	  children = children->next;
> 
> 	  if (page->tab_label)
>             {
>               if (notebook->show_tabs && GTK_WIDGET_VISIBLE (page->child))
>                 {
>                   if (GTK_WIDGET_VISIBLE (page->tab_label))
>                     {
>                       if (!GTK_WIDGET_MAPPED (page->tab_label))
>                          gtk_widget_map (page->tab_label);
>                     }
>                   else
>                     gtk_widget_show (page->tab_label);
>                 }
>               else 
>                 {
>                   if (GTK_WIDGET_VISIBLE (page->tab_label))
>                     GTK_WIDGET_HIDE (page->tab_label);
>                 }
> 	    }
>          }
> 
> That is probably overkill, since the show/hide is also going on in
> gtk_widget_size_request, so perhaps your fix is sufficient.  But I'd
> like to have a some idea of exactly how the problem is occurring
> before I start changing stuff.

Your fix looks better. The code should check notebook->show_tabs at least,
since gtk_notebook_size_request does not automatically hide tab_labels
in case of show_tabs == FALSE.

bye,
 Lars



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