Wireshark-dev: Re: [Wireshark-dev] New Wireshark welcome page!
From: "Jim Young" <sysjhy@xxxxxxxxxxxxxxx>
Date: Thu, 17 Apr 2008 23:18:05 -0400
Hello Ulf,

>>> Ulf Lamping <ulf.lamping@xxxxxx> 2008-04-17 04:35 >>>
>> Guy Harris schrieb:
>> Stig Bjørlykke wrote:
>>   
>>> On startup I get this warning:
>>> (wireshark:26750): Gtk-CRITICAL **: gtk_container_foreach:
assertion
>>> `GTK_IS_CONTAINER (container)' failed
>>>     
>> That appears to be happening in the gtk_container_foreach() call in

>> clear_menu_recent_capture_file_cmd_cb().  I haven't yet figured out
why 
>> the widget isn't considered a container.
>>   
>Interestingly, even after experimenting a bit I just don't get that 
> warning on XP.
>
> Could someone that get's the warning have a closer look?

After doing an svn update to 25109 (and applying a small patch 
to gtk/webbrowser.c to allow compilation to complete), I chased
down one source of the above "Gtk-CRITICAL" message.

In my case the call to get_container_get_children() in the first call
to 
gtk/main_welcome.c's main_welcome_reset_recent_capture_files()
triggered the error message.  This error seems to have appeared 
because welcome_file_panel_vb was NULL at this time.   The attached 
patch simply tests for a non-null welcome_file_panel_vb before 
attempting to get the child_list.

Is this the proper fix, or should welcome_file_panel_vb have actually
had a non-null value by the time
main_welcome_reset_recent_capture_files()
is first called?

Hope this helps.

Jim Y.


Index: gtk/main_welcome.c
===================================================================
--- gtk/main_welcome.c	(revision 25109)
+++ gtk/main_welcome.c	(working copy)
@@ -322,15 +322,17 @@
     GList* child_list;
     GList* child_list_item;
 
-    child_list = gtk_container_get_children(GTK_CONTAINER(welcome_file_panel_vb));
-    child_list_item = child_list;
+    if(welcome_file_panel_vb) {
+        child_list = gtk_container_get_children(GTK_CONTAINER(welcome_file_panel_vb));
+        child_list_item = child_list;
 
-    while(child_list_item) {
-        gtk_container_remove(GTK_CONTAINER(welcome_file_panel_vb), child_list_item->data);
-        child_list_item = g_list_next(child_list_item);
+        while(child_list_item) {
+            gtk_container_remove(GTK_CONTAINER(welcome_file_panel_vb), child_list_item->data);
+            child_list_item = g_list_next(child_list_item);
+        }
+
+        g_list_free(child_list);
     }
-
-    g_list_free(child_list);
 }
 
 
Index: gtk/webbrowser.c
===================================================================
--- gtk/webbrowser.c	(revision 25109)
+++ gtk/webbrowser.c	(working copy)
@@ -42,7 +42,10 @@
 
 #include "gtk/webbrowser.h"
 
+static gchar *
+filename2uri(const gchar *filename);
 
+
 /*
  * For GNOME 2.x, we might be able to use "gnome_url_show()" (when we offer
  * the ability to build a GNOMEified Wireshark as well as a GTK+-only
@@ -379,7 +382,7 @@
  * @return a newly allocated uri, you must g_free it later
  */
 static gchar *
-filename2uri(gchar *filename)
+filename2uri(const gchar *filename)
 {
     int i = 0;
     gchar *file_tmp;